using Indotalent.ConfigBackEnd.Interfaces; using Indotalent.ConfigFrontEnd.Common; using Indotalent.Features.Sales.SalesQuotation.Cqrs; using Indotalent.Infrastructure.Authentication.Identity; using Indotalent.Shared.Models; using Microsoft.AspNetCore.Components; using MudBlazor; using RestSharp; namespace Indotalent.Features.Sales.SalesQuotation; public class SalesQuotationService : BaseService { private readonly RestClient _client; public SalesQuotationService( IHttpClientFactory clientFactory, NavigationManager nav, ISnackbar snackbar, ICurrentUserService currentUserService, TokenProvider tokenProvider) : base(clientFactory, nav, snackbar, currentUserService, tokenProvider) { _client = new RestClient(nav.BaseUri); } public async Task>?> GetSalesQuotationListAsync() { var request = new RestRequest("api/sales-quotation", Method.Get); return await ExecuteWithResponseAsync>(_client, request); } public async Task?> GetSalesQuotationByIdAsync(string id) { var request = new RestRequest($"api/sales-quotation/{id}", Method.Get); return await ExecuteWithResponseAsync(_client, request); } public async Task?> GetSalesQuotationLookupAsync() { var request = new RestRequest("api/sales-quotation/lookup", Method.Get); return await ExecuteWithResponseAsync(_client, request); } public async Task?> CreateSalesQuotationAsync(CreateSalesQuotationRequest data) { var request = new RestRequest("api/sales-quotation", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task?> UpdateSalesQuotationAsync(UpdateSalesQuotationRequest data) { var request = new RestRequest("api/sales-quotation/update", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task DeleteSalesQuotationByIdAsync(string id) { var request = new RestRequest($"api/sales-quotation/delete/{id}", Method.Post); var response = await ExecuteWithResponseAsync(_client, request); return response?.IsSuccess ?? false; } public async Task?> CreateSalesQuotationItemAsync(CreateSalesQuotationItemRequest data) { var request = new RestRequest("api/sales-quotation/sales-quotation-item", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task?> UpdateSalesQuotationItemAsync(UpdateSalesQuotationItemRequest data) { var request = new RestRequest("api/sales-quotation/sales-quotation-item/update", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task DeleteSalesQuotationItemAsync(string id) { var request = new RestRequest($"api/sales-quotation/sales-quotation-item/delete/{id}", Method.Post); var response = await ExecuteWithResponseAsync(_client, request); return response?.IsSuccess ?? false; } }