This commit is contained in:
mmrbnjd
2024-07-27 23:20:15 +03:30
parent 97c30ce438
commit 888b63dcd4
6 changed files with 132 additions and 26 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

@@ -0,0 +1,63 @@
@using Front.Services
@using Shared.DTOs
@inject Fixedvalues fv;
@inject HttpClientController hc;
<Preload LoadingText="در حال بارگذاری..." />
<div class="row g-3">
<div class="col-md-2">
<Dropdown Color="DropdownColor.Secondary">
<DropdownToggleButton>نوع سفارش</DropdownToggleButton>
<DropdownMenu>
@foreach (var i in orderstype)
{
<DropdownItem @onclick="()=>OnChange(i.ID,i.Title)">@i.Title</DropdownItem>
}
</DropdownMenu>
</Dropdown>
</div>
<div class="col-md-6">
<label>@orderSelectName</label>
</div>
</div>
<div class="row g-3">
<div class="col-md-4">
<button type="submit" @onclick="NewOrder" class="btn btn-primary">ثبت</button>
</div>
</div>
@code {
string orderSelectName = "";
int orderSelectID = 0;
[Inject] protected PreloadService PreloadService { get; set; } = default!;
[Parameter] public EventCallback<OrderDto> OnMultipleOfThree { get; set; }
List<IdName<int>> orderstype = new List<IdName<int>>()
{ new IdName<int>() { ID=999,Title="شخصی" },
new IdName<int>() { ID=919,Title="qw" }};
public List<PromotionDto> Promotions { get; set; } = new();
public List<PricingDto> Pricing { get; set; } = new();
}
@functions {
protected override async Task OnParametersSetAsync()
{
Promotions = await fv.LoadPromotion();
Pricing = await fv.LoadPricing();
orderstype.AddRange(Promotions.Select(s => new IdName<int>
{
ID = s.ID,
Title = s.Name
}).ToList());
await base.OnParametersSetAsync();
}
public async Task OnChange(int ID,string Title)
{
orderSelectID = ID;
orderSelectName = Title;
}
public async Task NewOrder() { }
}

View File

@@ -179,9 +179,9 @@
private async Task OnClickPay() private async Task OnClickPay()
{ {
// result.Status = ComponentStatus.success; // result.Status = ComponentStatus.success;
// result.Action = ComponentAction.add; // result.Action = ComponentAction.add;
// await OnMultipleOfThree.InvokeAsync(result); // await OnMultipleOfThree.InvokeAsync(result);
} }
private async Task OnClickCancel() private async Task OnClickCancel()
@@ -193,15 +193,16 @@
if (confirmation) if (confirmation)
{ {
PreloadService.Show(SpinnerColor.Dark); PreloadService.Show(SpinnerColor.Dark);
var rsp = await hc.Get($"Orders/CancelOrder/{order.ID}"); var rsp = await hc.Get($"Orders/CancelOrder/{order.ID}");
PreloadService.Hide(); PreloadService.Hide();
if (rsp.IsSuccessStatusCode) if (rsp.IsSuccessStatusCode)
{
if(await rsp.Content.ReadFromJsonAsync<bool>())
{ {
result.Status = ComponentStatus.success; if(await rsp.Content.ReadFromJsonAsync<bool>())
{
order.Status = StatusOrder.Cancel;
result.Status = ComponentStatus.success;
result.Action = ComponentAction.delete; result.Action = ComponentAction.delete;
await OnMultipleOfThree.InvokeAsync(result); await OnMultipleOfThree.InvokeAsync(result);
} }

View File

@@ -1,4 +1,5 @@
using Front.Services; using BlazorBootstrap;
using Front.Services;
using Shared.DTOs; using Shared.DTOs;
using System.Net.Http.Json; using System.Net.Http.Json;
using System.Security.Cryptography; using System.Security.Cryptography;
@@ -16,6 +17,9 @@ namespace Front
private CompanyDTO? InfoCompany = null; private CompanyDTO? InfoCompany = null;
public InvoiceDTO? invoice { get; set; } = null; public InvoiceDTO? invoice { get; set; } = null;
public DashBoardDTO? dashBoard { get; set; } = null; public DashBoardDTO? dashBoard { get; set; } = null;
private List<PromotionDto>? Promotions { get; set; } = null;
private List<PricingDto>? Pricing { get; set; } = null;
public Fixedvalues(HttpClientController hc) public Fixedvalues(HttpClientController hc)
{ {
_hc = hc; _hc = hc;
@@ -77,7 +81,7 @@ namespace Front
return InfoCompany; return InfoCompany;
} }
public async Task<DashBoardDTO?> GetDashBoard(bool run=false) public async Task<DashBoardDTO?> GetDashBoard(bool run = false)
{ {
if (dashBoard == null || run) if (dashBoard == null || run)
@@ -106,10 +110,32 @@ namespace Front
} }
public async Task SetUlr(string Type) public async Task SetUlr(string Type)
{ {
await _hc.Post<UlrDto>("Base/Ulr",new UlrDto { Type=Type}); await _hc.Post<UlrDto>("Base/Ulr", new UlrDto { Type = Type });
}
public async Task<List<PricingDto>> LoadPricing()
{
if (Pricing == null)
{
var rsp = await _hc.Get($"Orders/GetAllPricing");
if (rsp.IsSuccessStatusCode)
Pricing = await rsp.Content.ReadFromJsonAsync<List<PricingDto>>();
}
return Pricing ?? new List<PricingDto>() ;
}
public async Task<List<PromotionDto>> LoadPromotion()
{
if(Promotions==null)
{var rsp = await _hc.Get($"Orders/GetAllPromotion");
if (rsp.IsSuccessStatusCode)
Promotions = await rsp.Content.ReadFromJsonAsync<List<PromotionDto>>();
}
return Promotions?? new List<PromotionDto>();
} }
} }

View File

@@ -8,6 +8,7 @@
@inject Fixedvalues fv; @inject Fixedvalues fv;
<PageTitle>سفارشات</PageTitle> <PageTitle>سفارشات</PageTitle>
<Modal Size="ModalSize.ExtraLarge" @ref="modal" /> <Modal Size="ModalSize.ExtraLarge" @ref="modal" />
<Modal Size="ModalSize.ExtraLarge" @ref="Newordermodal" />
<Preload LoadingText="در حال بارگذاری..." /> <Preload LoadingText="در حال بارگذاری..." />
@* search *@ @* search *@
<div class="row"> <div class="row">
@@ -59,7 +60,7 @@
<div class="row g-3"> <div class="row g-3">
<div class="col-auto"> <div class="col-auto">
<button type="submit" @onclick="()=>OrderItem(0)" class="btn btn-primary">جدید</button> <button type="submit" @onclick="NewOrderItem" class="btn btn-primary">جدید</button>
</div> </div>
@@ -120,6 +121,7 @@
public int? PageIndex { get; set; } public int? PageIndex { get; set; }
public Shared.DTOs.PagingDto<OrderDto>? request { get; set; } public Shared.DTOs.PagingDto<OrderDto>? request { get; set; }
private Modal modal = default!; private Modal modal = default!;
private Modal Newordermodal = default!;
// alert // alert
AlertColor alertColor = AlertColor.Primary; AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill; IconName alertIconName = IconName.CheckCircleFill;
@@ -185,20 +187,34 @@
if (result.Status == ComponentStatus.success) if (result.Status == ComponentStatus.success)
ShowSuccessAlert("سفارش ابطال شد"); ShowSuccessAlert("سفارش ابطال شد");
} }
if (result.Status == ComponentStatus.success) if (result.Status == ComponentStatus.success)
await GetOrders(1); await GetOrders(1);
await modal.HideAsync(); await modal.HideAsync();
} }
public async Task OrderItem(int ID) public async Task OrderItem(int ID)
{
await ReadOrderItem(request?.list.Where(w => w.ID == ID).First());
}
public async Task ReadOrderItem(OrderDto order)
{
var parameters = new Dictionary<string, object>();
parameters.Add("order", order);
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackFromReadItem));
await modal.ShowAsync<OrderItemRead>(title: $"سفارش {order.ID}", parameters: parameters);
}
public async Task CallBackFromNewItem(OrderDto result)
{
await Newordermodal.HideAsync();
}
public async Task NewOrderItem()
{ {
var parameters = new Dictionary<string, object>(); var parameters = new Dictionary<string, object>();
var item = request?.list.Where(w => w.ID == ID).First().Clone();
parameters.Add("order", item); parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<OrderDto>(this, CallBackFromNewItem));
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackFromReadItem)); await Newordermodal.ShowAsync<OrderItemNew>(title: $"سفارش جدید", parameters: parameters);
await modal.ShowAsync<OrderItemRead>(title:$"سفارش {ID}", parameters: parameters);
} }

View File

@@ -37,10 +37,10 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") }); //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") });
//Home //Home
//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/") });
//farzan //farzan
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");