using Indotalent.ConfigBackEnd.Interfaces; using Indotalent.ConfigFrontEnd.Common; using Indotalent.Features.Inventory.StockCount.Cqrs; using Indotalent.Infrastructure.Authentication.Identity; using Indotalent.Shared.Models; using Microsoft.AspNetCore.Components; using MudBlazor; using RestSharp; namespace Indotalent.Features.Inventory.StockCount; public class StockCountService : BaseService { private readonly RestClient _client; public StockCountService( IHttpClientFactory clientFactory, NavigationManager nav, ISnackbar snackbar, ICurrentUserService currentUserService, TokenProvider tokenProvider) : base(clientFactory, nav, snackbar, currentUserService, tokenProvider) { _client = new RestClient(nav.BaseUri); } public async Task>?> GetStockCountListAsync() { var request = new RestRequest("api/stock-count", Method.Get); return await ExecuteWithResponseAsync>(_client, request); } public async Task?> GetStockCountByIdAsync(string id) { var request = new RestRequest($"api/stock-count/{id}", Method.Get); return await ExecuteWithResponseAsync(_client, request); } public async Task?> GetStockCountLookupAsync() { var request = new RestRequest("api/stock-count/lookup", Method.Get); return await ExecuteWithResponseAsync(_client, request); } public async Task?> CreateStockCountAsync(CreateStockCountRequest data) { var request = new RestRequest("api/stock-count", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task?> UpdateStockCountAsync(UpdateStockCountRequest data) { var request = new RestRequest("api/stock-count/update", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task DeleteStockCountByIdAsync(string id) { var request = new RestRequest($"api/stock-count/delete/{id}", Method.Post); var response = await ExecuteWithResponseAsync(_client, request); return response?.IsSuccess ?? false; } public async Task?> CreateStockCountItemAsync(CreateStockCountItemRequest data) { var request = new RestRequest("api/stock-count/stock-count-item", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task?> UpdateStockCountItemAsync(UpdateStockCountItemRequest data) { var request = new RestRequest("api/stock-count/stock-count-item/update", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task DeleteStockCountItemAsync(string id) { var request = new RestRequest($"api/stock-count/stock-count-item/delete/{id}", Method.Post); var response = await ExecuteWithResponseAsync(_client, request); return response?.IsSuccess ?? false; } }