This commit is contained in:
mmrbnjd
2024-06-27 00:20:36 +03:30
parent 478456c03f
commit 94fdefa12c
8 changed files with 138 additions and 57 deletions

View File

@@ -36,7 +36,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="Service"> <Reference Include="Service">
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath> <HintPath>..\..\Dlls\Service.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>

View File

@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
using Shared.DTOs; using Shared.DTOs;
using Shared.DTOs.Serch;
namespace Back.Controllers namespace Back.Controllers
{ {
@@ -18,8 +19,8 @@ namespace Back.Controllers
{ {
_Servstuff = Servstuff; _Servstuff = Servstuff;
} }
[HttpGet("Getstuff/{value}")] [HttpPost("Getstuff")]
public async Task<ActionResult> Getstuff(string value) public async Task<ActionResult<PagingDto<stuffDto>>> Getstuff(GridDataProviderRequestDto value)
{ {
return Ok(await _Servstuff.Getstuff(value)); return Ok(await _Servstuff.Getstuff(value));
} }

View File

@@ -1,7 +1,9 @@
using Back.Data.Contracts; using Back.Common;
using Back.Data.Contracts;
using Back.Data.Models; using Back.Data.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Shared.DTOs; using Shared.DTOs;
using Shared.DTOs.Serch;
namespace Back.Services namespace Back.Services
{ {
@@ -12,10 +14,24 @@ namespace Back.Services
{ {
_repostuff=repostuff; _repostuff=repostuff;
} }
public async Task<List<stuffDto>> Getstuff(string value) public async Task<PagingDto<stuffDto>> 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 return await request.Select(s=>new stuffDto
{ {
DescriptionOfID=s.DescriptionOfID, DescriptionOfID=s.DescriptionOfID,
@@ -25,7 +41,7 @@ namespace Back.Services
Vat= string.IsNullOrEmpty(s.Vat) ? 0 :Convert.ToInt32(s.Vat), Vat= string.IsNullOrEmpty(s.Vat) ? 0 :Convert.ToInt32(s.Vat),
// VatCustomPurposes = string.IsNullOrEmpty(s.VatCustomPurposes) ? 0 : Convert.ToInt32(s.VatCustomPurposes) // VatCustomPurposes = string.IsNullOrEmpty(s.VatCustomPurposes) ? 0 : Convert.ToInt32(s.VatCustomPurposes)
}).ToListAsync(); }).Paging(value.PageNumber,value.PageSize);
} }
} }
} }

View File

@@ -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<FilterItem> Filters { get; init; }
public int PageNumber { get; init; }
public int PageSize { get; init; }
//public string sortString { get; init; }
//public string SortDirection { get; init; }
}
}

View File

@@ -1,66 +1,97 @@
@using Shared.DTOs; @using Shared.DTOs;
@using Front.Services @using Front.Services
@using Shared.DTOs.Serch
@inject HttpClientController hc; @inject HttpClientController hc;
<div class="mb-3 row">
<div class="col-md-10">
<InputText @bind-Value="@Value" onclick="" style="text-align:center;" class="form-control" placeholder="دنبال چی ؟" id="html5-password-input3" />
</div> <div class="col-md-2">
<button onclick="" type="submit" class="btn btn-primary">ارسال</button>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<Grid TItem="stuffDto" class="table table-hover table-bordered table-striped" DataProvider="DataProvider" AllowFiltering="true" Responsive="true" AllowPaging="true" PageSize="5"> <Grid TItem="stuffDto" class="table table-hover table-bordered table-striped" DataProvider="DataProvider" AllowFiltering="true" Responsive="true" AllowPaging="true" PageSize="10">
<GridColumn TItem="stuffDto" HeaderText="شناسه" PropertyName="Id"> <GridColumn Sortable="false" FilterOperator="FilterOperator.Contains" TItem="stuffDto" HeaderText="شناسه" PropertyName="ID">
@context.ID @context.ID
</GridColumn> </GridColumn>
<GridColumn TItem="stuffDto" HeaderText="نوع شناسه کالا" PropertyName="Type" StringComparison="StringComparison.Ordinal"> <GridColumn Sortable="false" FilterOperator="FilterOperator.Contains" TItem="stuffDto" HeaderText="شرح شناسه کالا" PropertyName="DescriptionOfID">
@context.DescriptionOfID
</GridColumn>
<GridColumn Sortable="false" Filterable="false" TItem="stuffDto" HeaderText="نوع شناسه کالا" PropertyName="Type">
@context.Type @context.Type
</GridColumn> </GridColumn>
<GridColumn TItem="stuffDto" HeaderText="مشمول یا معاف" PropertyName="TaxableOrFree"> <GridColumn Sortable="false" Filterable="false" TItem="stuffDto" HeaderText="وضعیت" PropertyName="TaxableOrFree">
@context.TaxableOrFree @context.TaxableOrFree
</GridColumn> </GridColumn>
<GridColumn TItem="stuffDto" HeaderText="نرخ ارزش افزوده" PropertyName="Vat"> <GridColumn Sortable="false" Filterable="false" TItem="stuffDto" HeaderText="نرخ" PropertyName="Vat">
@context.Vat @context.Vat
</GridColumn> </GridColumn>
@* <GridColumn TItem="stuffDto" HeaderText="نرخ ارزش افزوده مبادی گمرکی" PropertyName="VatCustomPurposes"> @* <GridColumn TItem="stuffDto" HeaderText="نرخ ارزش افزوده مبادی گمرکی" PropertyName="VatCustomPurposes">
@context.VatCustomPurposes @context.VatCustomPurposes
</GridColumn> *@ </GridColumn> *@
<GridColumn TItem="stuffDto" HeaderText="شرح شناسه کالا" PropertyName="DescriptionOfID">
@context.DescriptionOfID
</GridColumn>
</Grid> </Grid>
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-12">
<a href="https://stuffid.tax.gov.ir/" target="_blank" rel="noopener noreferrer">جستجوی پیشرفته</a>
</div>
</div>
@code { @code {
private IEnumerable<stuffDto> stuffDtos; // private IEnumerable<stuffDto> stuffDtos;
public string Value { get; set; } // public string Value { get; set; }
protected override void OnInitialized() // protected override void OnInitialized()
{ // {
stuffDtos = new List<stuffDto>(); // stuffDtos = new List<stuffDto>();
}
// }
} }
@functions { @functions {
public async Task Search() // public async Task Search()
{ // {
if (!string.IsNullOrEmpty(Value)) // if (!string.IsNullOrEmpty(Value))
{ // {
var rsp = await hc.Get($"stuff/Getstuff/{Value}"); // var rsp = await hc.Get($"stuff/Getstuff/{Value}");
if (rsp.IsSuccessStatusCode) // if (rsp.IsSuccessStatusCode)
{ // {
stuffDtos = await rsp.Content.ReadFromJsonAsync<List<stuffDto>>(); // stuffDtos = await rsp.Content.ReadFromJsonAsync<List<stuffDto>>();
} // }
} // }
} // }
private async Task<GridDataProviderResult<stuffDto>> DataProvider(GridDataProviderRequest<stuffDto> request) private async Task<GridDataProviderResult<stuffDto>> DataProvider(GridDataProviderRequest<stuffDto> 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<stuffDto>(0, 0, new List<stuffDto>());
var rsp = await hc.Post<GridDataProviderRequestDto>($"stuff/Getstuff", itemsearch);
if (rsp.IsSuccessStatusCode)
{
stuffDtos = await rsp.Content.ReadFromJsonAsync<PagingDto<stuffDto>>();
}
// var result = await _customerService.GetCustomersAsync(request.Filters, request.PageNumber, request.PageSize, sortString, sortDirection, request.CancellationToken);
return await Task.FromResult(new GridDataProviderResult<stuffDto> { Data = stuffDtos.list, TotalCount = stuffDtos.RowCount });
} }
} }

View File

@@ -57,23 +57,27 @@
@* action *@ @* action *@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="mb-2"> <ul class="list-group fa-padding" >
<div class="row"> <li class="list-group-item" data-toggle="modal" data-target="#issue">
<div class="col-md-10"> <div class="row g-3">
<div class="col-auto"> <div class="col-auto">
<button type="submit" @onclick="()=>CodItem(0)" class="btn btn-primary">جدید</button> <button type="submit" @onclick="()=>CodItem(0)" class="btn btn-primary">جدید</button>
</div> </div>
</div>
<div class="col-md-2">
<div class="col-auto"> <div class="col-auto">
<Button Color="ButtonColor.Info" @onclick="Showstuff" Type="ButtonType.Button"> <Button Color="ButtonColor.Info" @onclick="Showstuff" Type="ButtonType.Button">
دریافت شناسه کالا دریافت شناسه کالا
</Button> </Button>
</div> </div>
</div> </div>
</div>
</div> </li>
</ul>
</div> </div>
</div> </div>
@@ -222,7 +226,6 @@
{ {
var parameters = new Dictionary<string, object>(); var parameters = new Dictionary<string, object>();
modal.Size = ModalSize.ExtraLarge; modal.Size = ModalSize.ExtraLarge;
await modal.ShowAsync<Front.CUSComponent.Taxstuff>(title: "دریافت شناسه کالا", parameters: parameters); await modal.ShowAsync<Front.CUSComponent.Taxstuff>(title: "دریافت شناسه کالا", parameters: parameters);

View File

@@ -67,9 +67,7 @@
</div> </div>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@@ -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"); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");