creditdocuments in front
This commit is contained in:
@@ -197,5 +197,15 @@ namespace Back.Controllers
|
||||
return BadRequest(new List<string> { "سفارش در این حالت امکان پرداخت ندارد" });
|
||||
|
||||
}
|
||||
[HttpPost("GetCreditDocuments")]
|
||||
public async Task<ActionResult<PagingDto<CreditDocumentDto>>> GetCreditDocuments(GridDataProviderRequestDto value)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var Company = user.RolUsers.First().Company;
|
||||
int CompanyID = Company.ID;
|
||||
return Ok(await _servWalt.GetDocuments(value,CompanyID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,11 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Common;
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Extensions;
|
||||
using Shared.DTOs;
|
||||
using Shared.DTOs.Serch;
|
||||
using Shared.Enums;
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
@@ -15,5 +21,35 @@ namespace Back.Services
|
||||
{
|
||||
return await _repoCreditDocuments.AddBoolResultAsync(document);
|
||||
}
|
||||
public async Task<PagingDto<CreditDocumentDto>> GetDocuments(GridDataProviderRequestDto value,int CompanyID)
|
||||
{
|
||||
var request = _repoCreditDocuments.GetAll();
|
||||
foreach (var item in value.Filters)
|
||||
{
|
||||
switch (item.PropertyName)
|
||||
{
|
||||
case "Date":
|
||||
request = request.Where(w => w.Date.Contains(item.Value.Replace("/","")) || w.Date == item.Value);
|
||||
break;
|
||||
case "Type":
|
||||
if (item.Value=="0" || item.Value == "1")
|
||||
request = request.Where(w => w.type == (CreditDocumentType)Enum.Parse(typeof(CreditDocumentType), item.Value));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return await _repoCreditDocuments.Get(document=>document.CompanyID==CompanyID)
|
||||
.Select(s=>new CreditDocumentDto
|
||||
{
|
||||
Date=s.Date.ShamciToFormatShamci(),
|
||||
Title=s.Title,
|
||||
typeName = s.type.GetDisplayName(),
|
||||
type=s.type,
|
||||
Value=s.Value,
|
||||
})
|
||||
.Paging(value.PageNumber, value.PageSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user