From 85a72bc1ad0f0f9901964d0439ea6a4f953321c4 Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Wed, 29 May 2024 15:51:06 +0330 Subject: [PATCH] ... --- Back/Back.csproj | 2 +- Back/Controllers/InvoiceController.cs | 63 +++++++++++-------- Back/Services/servInvoice.cs | 21 +++++-- TaxPayerFull/Layout/NavMenu.razor | 2 +- .../Pages/UserPanel/InvoiceItem.razor | 52 +++++++++++---- TaxPayerFull/Program.cs | 4 +- 6 files changed, 96 insertions(+), 48 deletions(-) diff --git a/Back/Back.csproj b/Back/Back.csproj index a6bcdd4..52705f9 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -35,7 +35,7 @@ - ..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll + ..\..\Dlls\Service.dll diff --git a/Back/Controllers/InvoiceController.cs b/Back/Controllers/InvoiceController.cs index 50a8136..b7881d6 100644 --- a/Back/Controllers/InvoiceController.cs +++ b/Back/Controllers/InvoiceController.cs @@ -4,6 +4,7 @@ using Back.Services; using Back.Validations; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; using Shared.DTOs; using Shared.DTOs.Serch; @@ -38,7 +39,7 @@ namespace Back.Controllers } [HttpGet("Get/{ID}")] - public async Task?> GetAll(int ID) + public async Task?> GetAll(int ID) { var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); var UserID = claim.Value; @@ -191,7 +192,7 @@ namespace Back.Controllers return Ok(await _servInvoice.DeleteInvoice(invoice)); } [HttpPost("ChangeInvoiceType/{InvoiceID}")]// ok - public async Task> ChangeInvoiceType(int InvoiceID, InvoiceType invoiceType) + public async Task> ChangeInvoiceType(int InvoiceID, InvoiceType invoiceType) { //-----GetUserAndCompany var claim = HttpContext.User.Claims.First(c => c.Type == "UserID"); @@ -229,7 +230,7 @@ namespace Back.Controllers case InvoiceType.Repair: await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false); - return Ok(await _servInvoice.AddInvoice(new Invoice() + var result = await _servInvoice.AddInvoice(new Invoice() { Title = Invoice.Title, @@ -243,11 +244,13 @@ namespace Back.Controllers BillReference = Invoice.ID, IsDeleted = false, PatternID = Invoice.PatternID - }, false)); - + }, false); + if (result > 0) + return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID,result)); + break; case InvoiceType.BackFrmSale: await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false); - return Ok(await _servInvoice.AddInvoice(new Invoice() + var result1 = await _servInvoice.AddInvoice(new Invoice() { Title = Invoice.Title, @@ -261,7 +264,10 @@ namespace Back.Controllers BillReference = Invoice.ID, IsDeleted = false, PatternID = Invoice.PatternID - }, false)); + }, false); + if (result1 > 0) + return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result1)); + break; default: return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" }); @@ -286,8 +292,8 @@ namespace Back.Controllers { switch (invoiceType) { - case InvoiceType.Sale: - return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); + //case InvoiceType.Sale: + // return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); case InvoiceType.CANCEL: return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); @@ -320,7 +326,7 @@ namespace Back.Controllers case InvoiceType.BackFrmSale: await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false); - return Ok(await _servInvoice.AddInvoice(new Invoice() + var result2 = await _servInvoice.AddInvoice(new Invoice() { Title = Invoice.Title, @@ -334,7 +340,10 @@ namespace Back.Controllers BillReference = Invoice.ID, IsDeleted = false, PatternID = Invoice.PatternID - }, false)); + }, false); + if (result2 > 0) + return Ok(await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID, result2)); + break; default: return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" }); @@ -362,23 +371,23 @@ namespace Back.Controllers case InvoiceType.Cancellation: return Ok(await _servInvoice.ChangeInvoiceType(Invoice, invoiceType)); - case InvoiceType.Repair: - await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false); - return Ok(await _servInvoice.AddInvoice(new Invoice() - { + //case InvoiceType.Repair: + // await _servInvoice.ChangeInvoiceType(Invoice, invoiceType, false); + // return Ok(await _servInvoice.AddInvoice(new Invoice() + // { - Title = Invoice.Title, - Des = Invoice.Des, - invoiceType = invoiceType, - CustomerID = Invoice.CustomerID, - CompanyID = Invoice.CompanyID, - InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""), - InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""), - LastChangeUserID = Convert.ToInt32(UserID), - BillReference = Invoice.ID, - IsDeleted = false, - PatternID = Invoice.PatternID - }, false)); + // Title = Invoice.Title, + // Des = Invoice.Des, + // invoiceType = invoiceType, + // CustomerID = Invoice.CustomerID, + // CompanyID = Invoice.CompanyID, + // InvoicIssueDate = Invoice.InvoicIssueDate.Replace("/", ""), + // InvoiceDate = Invoice.InvoicIssueDate.Replace("/", ""), + // LastChangeUserID = Convert.ToInt32(UserID), + // BillReference = Invoice.ID, + // IsDeleted = false, + // PatternID = Invoice.PatternID + // }, false)); default: return BadRequest(new List { $"تغییر وضعیت از {Invoice.invoiceType.GetEnumDisplayName()} به {invoiceType.GetEnumDisplayName()} امکان پذیر نیست این صورتحساب به سامانه مودیان ارسال شده" }); diff --git a/Back/Services/servInvoice.cs b/Back/Services/servInvoice.cs index 5f6bf53..2eea248 100644 --- a/Back/Services/servInvoice.cs +++ b/Back/Services/servInvoice.cs @@ -92,7 +92,7 @@ namespace Back.Services { #region AdvancedSearch var invok = _invoiceRepo - .Get(w => w.CompanyID == CompanyID && !w.IsDeleted); + .Get(w => w.CompanyID == CompanyID && !w.IsDeleted && !w.BillReference.HasValue); if (itemSerch.InvoiceID != null) invok = invok.Where(w => w.ID == itemSerch.InvoiceID); @@ -209,7 +209,7 @@ namespace Back.Services } } - public async Task ChangeInvoiceType(Invoice invoiceitem, InvoiceType item, bool action = true) + public async Task ChangeInvoiceType(Invoice invoiceitem, InvoiceType item, bool action = true) { string old = invoiceitem.invoiceType.GetEnumDisplayName(); invoiceitem.invoiceType = item; @@ -226,8 +226,19 @@ namespace Back.Services UserID = invoiceitem.LastChangeUserID }); if (action) - return await _invoiceRepo.UpdateAsync(invoiceitem); - else return true; + { + var result = await _invoiceRepo.UpdateAsync(invoiceitem); + if (result) + { + return await GetInvoice(invoiceitem.CompanyID.Value, invoiceitem.ID); + } + else + { + return null; + } + + } + else return await GetInvoice(invoiceitem.CompanyID.Value, invoiceitem.ID); //_contextMongodb.InsertItem(new SysLog() //{ // TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier, @@ -249,7 +260,7 @@ namespace Back.Services // Route = _httpContextAccessor.HttpContext.Request.Path, // Type = "catch" //}); - return false; + return null; } diff --git a/TaxPayerFull/Layout/NavMenu.razor b/TaxPayerFull/Layout/NavMenu.razor index 53cf2fe..e6c2b86 100644 --- a/TaxPayerFull/Layout/NavMenu.razor +++ b/TaxPayerFull/Layout/NavMenu.razor @@ -10,7 +10,7 @@ + @* @if (invoice.BillReference.HasValue) + { +
+ +
+ } *@ +

@if (InvoiceID == 0 || InvoiceID == null) @@ -337,6 +344,27 @@ } + private async Task ChangeStatus(InvoiceType type) + { + var rsp = await hc.Post($"Invoice/ChangeInvoiceType/{InvoiceID}",type); + if (rsp.IsSuccessStatusCode) + { + var resinvoice = await rsp.Content.ReadFromJsonAsync(); + if (resinvoice!=null) + { + invoice = resinvoice; + ShowSuccessAlert("تغییر وضعیت با موفقیت انجام شد"); + } + else ShowDangerAlert("خطایی در اجرای عملیات رخ داده"); + } + else + { + var request = await rsp.Content.ReadFromJsonAsync>(); + ShowDangerAlert(request[0]); + } + + } + private async Task LoadData() { PreloadService.Show(SpinnerColor.Dark); 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");