...
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Service">
|
||||
<HintPath>..\..\Dlls\Service.dll</HintPath>
|
||||
<HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Back.Services;
|
||||
using Back.Common;
|
||||
using Back.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -11,14 +12,14 @@ namespace Back.Controllers
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class OrderssController : ControllerBase
|
||||
public class OrdersController : ControllerBase
|
||||
{
|
||||
private readonly ServOrders _servOrders;
|
||||
private readonly ServPromotion _servPromotion;
|
||||
private readonly ServPricing _servPricing;
|
||||
private readonly servUser _servUser;
|
||||
|
||||
public OrderssController(ServOrders servOrders, ServPromotion servPromotion, ServPricing servPricing, servUser servUser)
|
||||
public OrdersController(ServOrders servOrders, ServPromotion servPromotion, ServPricing servPricing, servUser servUser)
|
||||
{
|
||||
_servOrders = servOrders;
|
||||
_servPricing = servPricing;
|
||||
@@ -51,7 +52,27 @@ namespace Back.Controllers
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
int CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
return Ok(await _servOrders.GetOrderItems(CompanyID, OrderID));
|
||||
return Ok(await _servOrders.GetOrderItems( OrderID, CompanyID));
|
||||
}
|
||||
[HttpDelete("CancelOrder/{OrderID}")]
|
||||
public async Task<ActionResult<List<OrderItemDto>>> CancelOrder(int OrderID)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
int CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
var order =await _servOrders.GetOrder(OrderID, CompanyID);
|
||||
if (order==null)
|
||||
return NotFound();
|
||||
|
||||
if (order.Status==StatusOrder.Create)
|
||||
{
|
||||
order.Status = StatusOrder.Cancel;
|
||||
order.ApprovalDate = DateTime.Now.ConvertMiladiToShamsi();
|
||||
return Ok(await _servOrders.UpdateOrder(order));
|
||||
}
|
||||
else return BadRequest(new List<string> { "در این وضعیت امکان ابطال نیست" });
|
||||
}
|
||||
}
|
||||
}
|
@@ -33,8 +33,8 @@ namespace Back.Services
|
||||
return await request
|
||||
.Select(w => new OrderDto
|
||||
{
|
||||
ApprovalDate = w.ApprovalDate,
|
||||
DateCreate = w.DateCreate,
|
||||
ApprovalDate = w.ApprovalDate.ShamciToFormatShamci(),
|
||||
DateCreate = w.DateCreate.ShamciToFormatShamci(),
|
||||
ID = w.ID,
|
||||
PreDiscount = w.PreDiscount,
|
||||
Status = w.Status,
|
||||
@@ -46,7 +46,9 @@ namespace Back.Services
|
||||
}
|
||||
public async Task<List<OrderItemDto>> GetOrderItems(int OrderID,int CompanyID)
|
||||
{
|
||||
return await _repoOrderItem.Get(w => w.OrderID == OrderID && w.Order.CompanyID== CompanyID)
|
||||
return await _repoOrderItem.Get(w => w.OrderID == OrderID && w.Order.CompanyID == CompanyID)
|
||||
.Include(inc=>inc.Permission)
|
||||
.Include(inc=>inc.Promotion)
|
||||
.Select(s=>new OrderItemDto
|
||||
{
|
||||
OrderID = OrderID,
|
||||
@@ -55,9 +57,18 @@ namespace Back.Services
|
||||
Discount=s.Discount,
|
||||
ID = s.ID,
|
||||
Tax = s.Tax,
|
||||
Type= s.PermissionID.HasValue && !s.PromotionID.HasValue ? "" : !s.PermissionID.HasValue && s.PromotionID.HasValue ? "تعرفه" : "نامشخص",
|
||||
IDForType = s.PermissionID.HasValue && !s.PromotionID.HasValue ? s.PermissionID.Value : !s.PermissionID.HasValue && s.PromotionID.HasValue ? s.PromotionID.Value : 0
|
||||
Type= s.PermissionID.HasValue && !s.PromotionID.HasValue ? "سرویس" : !s.PermissionID.HasValue && s.PromotionID.HasValue ? "تعرفه" : "نامشخص",
|
||||
IDForType = s.PermissionID.HasValue && !s.PromotionID.HasValue ? s.PermissionID.Value : !s.PermissionID.HasValue && s.PromotionID.HasValue ? s.PromotionID.Value : 0,
|
||||
Title = s.PermissionID.HasValue && !s.PromotionID.HasValue ? s.Permission.Title : !s.PermissionID.HasValue && s.PromotionID.HasValue ? s.Promotion.Name : "",
|
||||
}).ToListAsync();
|
||||
}
|
||||
public async Task<Order> GetOrder(int OrderID, int CompanyID)
|
||||
{
|
||||
return await _repoOrder.Get(w => w.ID == OrderID && w.CompanyID == CompanyID) .FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<bool> UpdateOrder(Order order)
|
||||
{
|
||||
return await _repoOrder.UpdateAsync(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,9 +23,9 @@ namespace Shared.DTOs
|
||||
public decimal PreDiscount { get; set; }
|
||||
[Display(Name = "تخفیف سفارش")]
|
||||
public decimal TDiscount { get; set; }
|
||||
[Display(Name = "مبلغ بغد از تخفیف")]
|
||||
[Display(Name = "بغد از تخفیف")]
|
||||
public decimal lstDiscount { get; set; }
|
||||
[Display(Name = "مبلغ مالیات")]
|
||||
[Display(Name = "مالیات")]
|
||||
public decimal TTax { get; set; }
|
||||
[Display(Name = "مبلغ نهایی")]
|
||||
public decimal TPrice { get; set; }
|
||||
|
@@ -9,6 +9,7 @@ namespace Shared.DTOs
|
||||
public class OrderItemDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Title { get; set; }
|
||||
public int OrderID { get; set; }
|
||||
public string Type { get; set; }
|
||||
public int IDForType { get; set; }
|
||||
|
@@ -2,6 +2,8 @@
|
||||
@using Shared.DTOs
|
||||
@inject HttpClientController hc;
|
||||
<Preload LoadingText="در حال بارگذاری..." />
|
||||
<ConfirmDialog @ref="dialog" />
|
||||
|
||||
@* alert *@
|
||||
<div class="row">
|
||||
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
|
||||
@@ -11,24 +13,103 @@
|
||||
|
||||
</div>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-2">
|
||||
<label class="col-sm-5 col-form-label">وضغیت</label>
|
||||
<InputText @value="order.StatusTitle" type="text" class="form-control" id="StatusTitle" placeholder="وضغیت" />
|
||||
<input style="text-align: center;" value="@order.StatusTitle" type="text" class="form-control" id="StatusTitle" placeholder="وضغیت" readonly />
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-2">
|
||||
<label class="col-sm-5 col-form-label">تاریخ ایحاد</label>
|
||||
<InputText @bind-Value="order.DateCreate" type="text" class="form-control" id="DateCreate" placeholder="تاریخ ایجاد" />
|
||||
<InputText style="text-align: center;" @bind-Value="order.DateCreate" type="text" class="form-control" id="DateCreate" placeholder="تاریخ ایجاد" readonly />
|
||||
</div>
|
||||
@if (order.Status!=StatusOrder.Create)
|
||||
@if (order.Status != StatusOrder.Create)
|
||||
{
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-2">
|
||||
<label class="col-sm-5 col-form-label">@titledateapp</label>
|
||||
<InputText @bind-Value="order.ApprovalDate" type="text" class="form-control" id="ApprovalDate" placeholder="@titledateapp" />
|
||||
<InputText style="text-align: center;" @bind-Value="order.ApprovalDate" type="text" class="form-control" id="ApprovalDate" placeholder="@titledateapp" readonly />
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<hr class="hr" />
|
||||
<div class="row g-3">
|
||||
<Grid @ref="grid" TItem="OrderItemDto"
|
||||
AllowRowClick="true"
|
||||
AllowSorting="true"
|
||||
Class="table table-hover"
|
||||
DataProvider="DataProvider"
|
||||
AllowPaging="true"
|
||||
PageSize="10"
|
||||
Responsive="true">
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="عنوان">
|
||||
@context.Title
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="نوع">
|
||||
@context.Type
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="تعداد">
|
||||
@context.CreditAmount
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="قیمت واحد">
|
||||
@context.APrice.ToString("N0")
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="تخفیف">
|
||||
@context.Discount.ToString("N0")
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="مالیات">
|
||||
@context.Tax.ToString("N0")
|
||||
</GridColumn>
|
||||
<GridColumn TItem="OrderItemDto" HeaderText="مبلغ کل">
|
||||
@context.Total.ToString("N0")
|
||||
</GridColumn>
|
||||
</Grid>
|
||||
|
||||
</div>
|
||||
<hr class="hr" />
|
||||
<div class="row g-3">
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="col-sm-5 col-form-label">مبلغ سفارش</label>
|
||||
<CurrencyInput style="text-align: center;" TValue="decimal" @bind-Value="order.PreDiscount" Locale="fa-Ir" Placeholder="مبلغ سفارش" readonly />
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="col-sm-5 col-form-label">تخفیف سفارش</label>
|
||||
<CurrencyInput style="text-align: center;" TValue="decimal" @bind-Value="order.TDiscount" Locale="fa-Ir" Placeholder="تخفیف سفارش" readonly />
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="col-sm-5 col-form-label">مالیات</label>
|
||||
<CurrencyInput style="text-align: center;" TValue="decimal" @bind-Value="order.TTax" Locale="fa-Ir" Placeholder="مالیات" readonly />
|
||||
</div>
|
||||
|
||||
@* <div class="col-md-4">
|
||||
<label class="col-sm-5 col-form-label">بغد از تخفیف</label>
|
||||
<CurrencyInput TValue="decimal" @bind-Value="order.lstDiscount" Locale="fa-Ir" Placeholder="بغد از تخفیف" readonly />
|
||||
</div> *@
|
||||
<div class="col-md-3">
|
||||
<label class="col-sm-5 col-form-label">مبلغ نهایی</label>
|
||||
<CurrencyInput style="text-align: center;" TValue="decimal" @bind-Value="order.TTax" Locale="fa-Ir" Placeholder="مبلغ نهایی" readonly />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<br />
|
||||
@if (order.Status == StatusOrder.Create)
|
||||
{
|
||||
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickPay" Type="ButtonType.Button">
|
||||
پرداخت
|
||||
</Button>
|
||||
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickCancel" Type="ButtonType.Button">
|
||||
ابطال
|
||||
</Button>
|
||||
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
#region Alert
|
||||
@@ -38,7 +119,9 @@
|
||||
bool Hidealert = true;
|
||||
string alertMessage = "";
|
||||
#endregion
|
||||
|
||||
private ConfirmDialog dialog = default!;
|
||||
public ActionInResultComponent result { get; set; }
|
||||
Grid<OrderItemDto> grid = default!;
|
||||
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
||||
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
|
||||
[Parameter] public OrderDto order { get; set; }
|
||||
@@ -46,7 +129,7 @@
|
||||
string titledateapp = "تاریخ";
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (order.Status==StatusOrder.Cancel)
|
||||
if (order.Status == StatusOrder.Cancel)
|
||||
{
|
||||
titledateapp += " ابطال";
|
||||
}
|
||||
@@ -57,7 +140,13 @@
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@functions{
|
||||
@functions {
|
||||
private async Task<GridDataProviderResult<OrderItemDto>> DataProvider(GridDataProviderRequest<OrderItemDto> request)
|
||||
{
|
||||
OrderItems = await LoadOrderItem(); // call a service or an API to pull the employees
|
||||
|
||||
return await Task.FromResult(request.ApplyTo(OrderItems));
|
||||
}
|
||||
private void ShowSuccessAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
@@ -72,14 +161,62 @@
|
||||
alertIconName = IconName.ExclamationTriangleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
private async Task LoadOrderItem(){
|
||||
private async Task<List<OrderItemDto>> LoadOrderItem()
|
||||
{
|
||||
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Get($"Orderss/GetOrderDetails/{order.ID}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
OrderItems = await rsp.Content.ReadFromJsonAsync<List<OrderItemDto>?>();
|
||||
else
|
||||
ShowDangerAlert("خطایی در بارگیری");
|
||||
var rsp = await hc.Get($"Orders/GetOrderDetails/{order.ID}");
|
||||
PreloadService.Hide();
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
return await rsp.Content.ReadFromJsonAsync<List<OrderItemDto>?>();
|
||||
else
|
||||
{
|
||||
ShowDangerAlert("خطایی در بارگیری");
|
||||
return new List<OrderItemDto>();
|
||||
}
|
||||
|
||||
}
|
||||
private async Task OnClickPay()
|
||||
{
|
||||
// result.Status = ComponentStatus.success;
|
||||
// result.Action = ComponentAction.add;
|
||||
// await OnMultipleOfThree.InvokeAsync(result);
|
||||
|
||||
|
||||
}
|
||||
private async Task OnClickCancel()
|
||||
{
|
||||
var confirmation = await dialog.ShowAsync(
|
||||
title: "عملیات ابطال سفارش",
|
||||
message1: $"از ابطال سفارش {order.ID}",
|
||||
message2: "اطمینان دارید?");
|
||||
|
||||
if (confirmation)
|
||||
{
|
||||
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Get($"Orders/CancelOrder/{order.ID}");
|
||||
PreloadService.Hide();
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
if(await rsp.Content.ReadFromJsonAsync<bool>())
|
||||
{
|
||||
result.Status = ComponentStatus.success;
|
||||
result.Action = ComponentAction.delete;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
else
|
||||
ShowDangerAlert("خطای سیستمی");
|
||||
}
|
||||
else if (rsp.StatusCode==System.Net.HttpStatusCode.NotFound)
|
||||
ShowDangerAlert("سفارش یافت نشد");
|
||||
|
||||
else
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowDangerAlert(request[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -148,7 +148,7 @@
|
||||
itemsearch.PageSize = 10;
|
||||
itemsearch.PageIndex = pi;
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Post<ItemSerachOrder>("Orderss/GetAllOrder",itemsearch);
|
||||
var rsp = await hc.Post<ItemSerachOrder>("Orders/GetAllOrder",itemsearch);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
request = await rsp.Content.ReadFromJsonAsync<Shared.DTOs.PagingDto<OrderDto>?>();
|
||||
else
|
||||
@@ -171,20 +171,15 @@
|
||||
alertMessage = msg;
|
||||
}
|
||||
|
||||
public async Task CallBackItem(ActionInResultComponent result)
|
||||
public async Task CallBackFromReadItem(ActionInResultComponent result)
|
||||
{
|
||||
|
||||
if (result.Action == ComponentAction.add)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
ShowSuccessAlert("سفارش جدید با موفقیت اضافه شد");
|
||||
ShowSuccessAlert("سفارش پرداخت شد");
|
||||
|
||||
}
|
||||
else if (result.Action == ComponentAction.update)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
ShowSuccessAlert("اطلاعات سفارش با موفقیت ویرایش شد");
|
||||
}
|
||||
else if (result.Action == ComponentAction.delete)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
@@ -200,10 +195,10 @@
|
||||
{
|
||||
var parameters = new Dictionary<string, object>();
|
||||
|
||||
var item = request.list.Where(w => w.ID == ID).First().Clone();
|
||||
var item = request?.list.Where(w => w.ID == ID).First().Clone();
|
||||
parameters.Add("order", item);
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackItem));
|
||||
await modal.ShowAsync<CodItem>(title:$"سفارش {ID}", parameters: parameters);
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackFromReadItem));
|
||||
await modal.ShowAsync<OrderItemRead>(title:$"سفارش {ID}", parameters: parameters);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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/") });
|
||||
|
||||
//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
|
||||
//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");
|
||||
|
||||
|
Reference in New Issue
Block a user