From 94fdefa12c6e95b2c50ba30e374da83663004a9f Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Thu, 27 Jun 2024 00:20:36 +0330 Subject: [PATCH] ... --- Back/Back.csproj | 2 +- Back/Controllers/stuffController.cs | 5 +- Back/Services/Servstuff.cs | 26 ++++- .../DTOs/Serch/GridDataProviderResultDto.cs | 32 ++++++ TaxPayerFull/CUSComponent/Taxstuff.razor | 103 ++++++++++++------ TaxPayerFull/Pages/UserPanel/COD.razor | 21 ++-- TaxPayerFull/Pages/UserPanel/Ticket.razor | 2 - TaxPayerFull/Program.cs | 4 +- 8 files changed, 138 insertions(+), 57 deletions(-) create mode 100644 Shared/DTOs/Serch/GridDataProviderResultDto.cs diff --git a/Back/Back.csproj b/Back/Back.csproj index 899d7e4..fd97cd7 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -36,7 +36,7 @@ - ..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll + ..\..\Dlls\Service.dll diff --git a/Back/Controllers/stuffController.cs b/Back/Controllers/stuffController.cs index dcb5c7e..06e4862 100644 --- a/Back/Controllers/stuffController.cs +++ b/Back/Controllers/stuffController.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Shared.DTOs; +using Shared.DTOs.Serch; namespace Back.Controllers { @@ -18,8 +19,8 @@ namespace Back.Controllers { _Servstuff = Servstuff; } - [HttpGet("Getstuff/{value}")] - public async Task Getstuff(string value) + [HttpPost("Getstuff")] + public async Task>> Getstuff(GridDataProviderRequestDto value) { return Ok(await _Servstuff.Getstuff(value)); } diff --git a/Back/Services/Servstuff.cs b/Back/Services/Servstuff.cs index 8ca27df..435ebf6 100644 --- a/Back/Services/Servstuff.cs +++ b/Back/Services/Servstuff.cs @@ -1,7 +1,9 @@ -using Back.Data.Contracts; +using Back.Common; +using Back.Data.Contracts; using Back.Data.Models; using Microsoft.EntityFrameworkCore; using Shared.DTOs; +using Shared.DTOs.Serch; namespace Back.Services { @@ -12,10 +14,24 @@ namespace Back.Services { _repostuff=repostuff; } - public async Task> Getstuff(string value) + public async Task> Getstuff(GridDataProviderRequestDto value) { - var request = _repostuff.Get(w => w.sType.Contains(value) || w.DescriptionOfID.Contains(value) || w.CID.Contains(value)); - + //Contains + var request = _repostuff.GetAll(); + foreach (var item in value.Filters) + { + switch (item.PropertyName) + { + case "ID": + request = request.Where(w=>w.CID.Contains( item.Value)); + break; + case "DescriptionOfID": + request = request.Where(w => w.DescriptionOfID.Contains(item.Value)); + break; + default: + break; + } + } return await request.Select(s=>new stuffDto { DescriptionOfID=s.DescriptionOfID, @@ -25,7 +41,7 @@ namespace Back.Services Vat= string.IsNullOrEmpty(s.Vat) ? 0 :Convert.ToInt32(s.Vat), // VatCustomPurposes = string.IsNullOrEmpty(s.VatCustomPurposes) ? 0 : Convert.ToInt32(s.VatCustomPurposes) - }).ToListAsync(); + }).Paging(value.PageNumber,value.PageSize); } } } diff --git a/Shared/DTOs/Serch/GridDataProviderResultDto.cs b/Shared/DTOs/Serch/GridDataProviderResultDto.cs new file mode 100644 index 0000000..3466031 --- /dev/null +++ b/Shared/DTOs/Serch/GridDataProviderResultDto.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.DTOs.Serch +{ + public class FilterItem + { + public string Oper { get; set; } + public string PropertyName { get; set; } + public string Value { get; set; } + } + + public class GridDataProviderRequestDto + { + // public CancellationToken CancellationToken { get; init; } + + public IEnumerable Filters { get; init; } + + public int PageNumber { get; init; } + + public int PageSize { get; init; } + + //public string sortString { get; init; } + //public string SortDirection { get; init; } + + + } +} diff --git a/TaxPayerFull/CUSComponent/Taxstuff.razor b/TaxPayerFull/CUSComponent/Taxstuff.razor index c7494b5..e82ee13 100644 --- a/TaxPayerFull/CUSComponent/Taxstuff.razor +++ b/TaxPayerFull/CUSComponent/Taxstuff.razor @@ -1,66 +1,97 @@ @using Shared.DTOs; @using Front.Services +@using Shared.DTOs.Serch @inject HttpClientController hc; -
-
- -
- -
-
- - + + @context.ID - + + @context.DescriptionOfID + + @context.Type - + @context.TaxableOrFree - + @context.Vat @* @context.VatCustomPurposes *@ - - @context.DescriptionOfID - +
+ @code { - private IEnumerable stuffDtos; - public string Value { get; set; } - protected override void OnInitialized() - { - stuffDtos = new List(); - + // private IEnumerable stuffDtos; + // public string Value { get; set; } + // protected override void OnInitialized() + // { + // stuffDtos = new List(); - } + + // } } @functions { - public async Task Search() - { - if (!string.IsNullOrEmpty(Value)) - { - var rsp = await hc.Get($"stuff/Getstuff/{Value}"); - if (rsp.IsSuccessStatusCode) - { - stuffDtos = await rsp.Content.ReadFromJsonAsync>(); - } - } - - } - + // public async Task Search() + // { + // if (!string.IsNullOrEmpty(Value)) + // { + // var rsp = await hc.Get($"stuff/Getstuff/{Value}"); + // if (rsp.IsSuccessStatusCode) + // { + // stuffDtos = await rsp.Content.ReadFromJsonAsync>(); + // } + // } + + // } + private async Task> DataProvider(GridDataProviderRequest request) { - return await Task.FromResult(request.ApplyTo(stuffDtos)); + 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 stuffDtos = new PagingDto(0, 0, new List()); + var rsp = await hc.Post($"stuff/Getstuff", itemsearch); + if (rsp.IsSuccessStatusCode) + { + stuffDtos = await rsp.Content.ReadFromJsonAsync>(); + } + + // var result = await _customerService.GetCustomersAsync(request.Filters, request.PageNumber, request.PageSize, sortString, sortDirection, request.CancellationToken); + return await Task.FromResult(new GridDataProviderResult { Data = stuffDtos.list, TotalCount = stuffDtos.RowCount }); } } \ No newline at end of file diff --git a/TaxPayerFull/Pages/UserPanel/COD.razor b/TaxPayerFull/Pages/UserPanel/COD.razor index 5312505..cd0a7ea 100644 --- a/TaxPayerFull/Pages/UserPanel/COD.razor +++ b/TaxPayerFull/Pages/UserPanel/COD.razor @@ -57,23 +57,27 @@ @* action *@
-
-
-
+
    +
  • +
    + + +
    - -
    -
    + +
    -
-
+ + + +
@@ -222,7 +226,6 @@ { var parameters = new Dictionary(); modal.Size = ModalSize.ExtraLarge; - await modal.ShowAsync(title: "دریافت شناسه کالا", parameters: parameters); diff --git a/TaxPayerFull/Pages/UserPanel/Ticket.razor b/TaxPayerFull/Pages/UserPanel/Ticket.razor index 6fdfff7..c261073 100644 --- a/TaxPayerFull/Pages/UserPanel/Ticket.razor +++ b/TaxPayerFull/Pages/UserPanel/Ticket.razor @@ -67,9 +67,7 @@
- - diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs index f8805c2..628e6c3 100644 --- a/TaxPayerFull/Program.cs +++ b/TaxPayerFull/Program.cs @@ -34,9 +34,9 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO() }) ; -//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); +//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");