Files
moadiran/Back/Services/Servstuff.cs

48 lines
1.7 KiB
C#
Raw Permalink Normal View History

2024-06-27 00:20:36 +03:30
using Back.Common;
using Back.Data.Contracts;
2024-06-26 17:10:29 +03:30
using Back.Data.Models;
using Microsoft.EntityFrameworkCore;
using Shared.DTOs;
2024-06-27 00:20:36 +03:30
using Shared.DTOs.Serch;
2024-06-26 17:10:29 +03:30
namespace Back.Services
{
public class Servstuff
{
private readonly IAsyncRepository<stuff> _repostuff;
public Servstuff(IAsyncRepository<stuff> repostuff)
{
_repostuff=repostuff;
}
2024-06-27 00:20:36 +03:30
public async Task<PagingDto<stuffDto>> Getstuff(GridDataProviderRequestDto value)
2024-06-26 17:10:29 +03:30
{
2024-06-27 00:20:36 +03:30
//Contains
var request = _repostuff.GetAll();
foreach (var item in value.Filters)
{
switch (item.PropertyName)
{
case "ID":
2024-06-28 18:31:12 +03:30
request = request.Where(w=>w.CID.Contains( item.Value) || w.CID == item.Value);
2024-06-27 00:20:36 +03:30
break;
case "DescriptionOfID":
2024-06-28 18:31:12 +03:30
request = request.Where(w => w.DescriptionOfID.Contains(item.Value) || w.DescriptionOfID == item.Value);
2024-06-27 00:20:36 +03:30
break;
default:
break;
}
}
2024-06-26 17:10:29 +03:30
return await request.Select(s=>new stuffDto
{
DescriptionOfID=s.DescriptionOfID,
ID=string.IsNullOrEmpty(s.CID) ? 0 :Convert.ToUInt64(s.CID),
TaxableOrFree=s.TaxableOrFree,
Type=s.sType,
Vat= string.IsNullOrEmpty(s.Vat) ? 0 :Convert.ToInt32(s.Vat),
// VatCustomPurposes = string.IsNullOrEmpty(s.VatCustomPurposes) ? 0 : Convert.ToInt32(s.VatCustomPurposes)
2024-06-27 00:20:36 +03:30
}).Paging(value.PageNumber,value.PageSize);
2024-06-26 17:10:29 +03:30
}
}
}