using Indotalent.ConfigBackEnd.Interfaces; using Indotalent.ConfigFrontEnd.Common; using Indotalent.Features.Inventory.NegativeAdjustment.Cqrs; using Indotalent.Infrastructure.Authentication.Identity; using Indotalent.Shared.Models; using Microsoft.AspNetCore.Components; using MudBlazor; using RestSharp; namespace Indotalent.Features.Inventory.NegativeAdjustment; public class NegativeAdjustmentService : BaseService { private readonly RestClient _client; public NegativeAdjustmentService( IHttpClientFactory clientFactory, NavigationManager nav, ISnackbar snackbar, ICurrentUserService currentUserService, TokenProvider tokenProvider) : base(clientFactory, nav, snackbar, currentUserService, tokenProvider) { _client = new RestClient(nav.BaseUri); } public async Task>?> GetNegativeAdjustmentListAsync() { var request = new RestRequest("api/negative-adjustment", Method.Get); return await ExecuteWithResponseAsync>(_client, request); } public async Task?> GetNegativeAdjustmentByIdAsync(string id) { var request = new RestRequest($"api/negative-adjustment/{id}", Method.Get); return await ExecuteWithResponseAsync(_client, request); } public async Task?> GetNegativeAdjustmentLookupAsync() { var request = new RestRequest("api/negative-adjustment/lookup", Method.Get); return await ExecuteWithResponseAsync(_client, request); } public async Task?> CreateNegativeAdjustmentAsync(CreateNegativeAdjustmentRequest data) { var request = new RestRequest("api/negative-adjustment", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task?> UpdateNegativeAdjustmentAsync(UpdateNegativeAdjustmentRequest data) { var request = new RestRequest("api/negative-adjustment/update", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task DeleteNegativeAdjustmentByIdAsync(string id) { var request = new RestRequest($"api/negative-adjustment/delete/{id}", Method.Post); var response = await ExecuteWithResponseAsync(_client, request); return response?.IsSuccess ?? false; } public async Task?> CreateNegativeAdjustmentItemAsync(CreateNegativeAdjustmentItemRequest data) { var request = new RestRequest("api/negative-adjustment/negative-adjustment-item", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task?> UpdateNegativeAdjustmentItemAsync(UpdateNegativeAdjustmentItemRequest data) { var request = new RestRequest("api/negative-adjustment/negative-adjustment-item/update", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task DeleteNegativeAdjustmentItemAsync(string id) { var request = new RestRequest($"api/negative-adjustment/negative-adjustment-item/delete/{id}", Method.Post); var response = await ExecuteWithResponseAsync(_client, request); return response?.IsSuccess ?? false; } }