creditdocuments in front
This commit is contained in:
@@ -197,5 +197,15 @@ namespace Back.Controllers
|
|||||||
return BadRequest(new List<string> { "سفارش در این حالت امکان پرداخت ندارد" });
|
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 Back.Data.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.OpenApi.Extensions;
|
||||||
|
using Shared.DTOs;
|
||||||
|
using Shared.DTOs.Serch;
|
||||||
|
using Shared.Enums;
|
||||||
|
|
||||||
namespace Back.Services
|
namespace Back.Services
|
||||||
{
|
{
|
||||||
@@ -15,5 +21,35 @@ namespace Back.Services
|
|||||||
{
|
{
|
||||||
return await _repoCreditDocuments.AddBoolResultAsync(document);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
Shared/DTOs/CreditDocumentDto.cs
Normal file
18
Shared/DTOs/CreditDocumentDto.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Shared.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Shared.DTOs
|
||||||
|
{
|
||||||
|
public class CreditDocumentDto
|
||||||
|
{
|
||||||
|
public string Date { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string typeName { get; set; }
|
||||||
|
public CreditDocumentType type { get; set; }
|
||||||
|
public decimal Value { get; set; }
|
||||||
|
}
|
||||||
|
}
|
76
TaxPayerFull/CUSComponent/CreditDocuments.razor
Normal file
76
TaxPayerFull/CUSComponent/CreditDocuments.razor
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
@using Front.Services
|
||||||
|
@using Shared.DTOs
|
||||||
|
@using Shared.DTOs.Serch
|
||||||
|
@inject HttpClientController hc;
|
||||||
|
<Grid TItem="CreditDocumentDto"
|
||||||
|
Class="table table-hover table-bordered table-striped"
|
||||||
|
DataProvider="DocumentDataProvider"
|
||||||
|
AllowFiltering="true"
|
||||||
|
AllowPaging="true"
|
||||||
|
AllowSorting="true"
|
||||||
|
Responsive="true">
|
||||||
|
|
||||||
|
<GridColumn TItem="CreditDocumentDto" HeaderText="تاریخ" PropertyName="Date" SortString="Date" SortKeySelector="item => item.Date" FilterTextboxWidth="50" HeaderTextAlignment="Alignment.Center" TextAlignment="Alignment.Center">
|
||||||
|
@context.Date
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CreditDocumentDto" Sortable="false" Filterable="false" HeaderText="عنوان" PropertyName="Title" FilterTextboxWidth="80">
|
||||||
|
@context.Title
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn TItem="CreditDocumentDto" HeaderText="حالت" PropertyName="typeName" SortString="typeName" SortKeySelector="item => item.typeName" FilterTextboxWidth="100">
|
||||||
|
@context.typeName
|
||||||
|
</GridColumn>
|
||||||
|
<GridColumn Sortable="false" Filterable="false" TItem="CreditDocumentDto" HeaderText="مقدار" PropertyName="Value" FilterTextboxWidth="120">
|
||||||
|
@context.Value
|
||||||
|
</GridColumn>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
|
||||||
|
private async Task<GridDataProviderResult<CreditDocumentDto>> DocumentDataProvider(GridDataProviderRequest<CreditDocumentDto> request)
|
||||||
|
{
|
||||||
|
string sortString = "";
|
||||||
|
SortDirection sortDirection = SortDirection.None;
|
||||||
|
|
||||||
|
if (request.Sorting is not null && request.Sorting.Any())
|
||||||
|
{
|
||||||
|
// Note: Multi column sorting is not supported at this moment
|
||||||
|
sortString = request.Sorting.FirstOrDefault()!.SortString;
|
||||||
|
sortDirection = request.Sorting.FirstOrDefault()!.SortDirection;
|
||||||
|
}
|
||||||
|
var itemsearch = new GridDataProviderRequestDto()
|
||||||
|
{
|
||||||
|
// CancellationToken = request.CancellationToken,
|
||||||
|
Filters = request.Filters.Select(s => new Shared.DTOs.Serch.FilterItem
|
||||||
|
{
|
||||||
|
Oper = s.Operator.ToString(),
|
||||||
|
PropertyName = s.PropertyName,
|
||||||
|
Value = s.Value
|
||||||
|
}).ToList(),
|
||||||
|
PageNumber = request.PageNumber,
|
||||||
|
PageSize = request.PageSize,
|
||||||
|
//sortString = sortString,
|
||||||
|
// SortDirection = sortDirection.ToString()
|
||||||
|
};
|
||||||
|
var model = new PagingDto<CreditDocumentDto>(0, 0, new List<CreditDocumentDto>());
|
||||||
|
var rsp = await hc.Post<GridDataProviderRequestDto>($"Orders/GetCreditDocuments", itemsearch);
|
||||||
|
if (rsp.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
model = await rsp.Content.ReadFromJsonAsync<PagingDto<CreditDocumentDto>>();
|
||||||
|
}
|
||||||
|
return await Task.FromResult(new GridDataProviderResult<CreditDocumentDto> { Data = model.list, TotalCount = model.RowCount });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// if (request.Sorting is not null && request.Sorting.Any())
|
||||||
|
// {
|
||||||
|
// // Note: Multi column sorting is not supported at this moment
|
||||||
|
// sortString = request.Sorting.FirstOrDefault()!.SortString;
|
||||||
|
// sortDirection = request.Sorting.FirstOrDefault()!.SortDirection;
|
||||||
|
// }
|
||||||
|
// var result = await _customerService.GetCustomersAsync(request.Filters, request.PageNumber, request.PageSize, sortString, sortDirection, request.CancellationToken);
|
||||||
|
// return await Task.FromResult(new GridDataProviderResult<Customer2> { Data = result.Item1, TotalCount = result.Item2 });
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user