using Indotalent.ConfigBackEnd.Interfaces; using Indotalent.ConfigFrontEnd.Common; using Indotalent.Features.Thirdparty.CustomerGroup.Cqrs; using Indotalent.Infrastructure.Authentication.Identity; using Indotalent.Shared.Models; using Microsoft.AspNetCore.Components; using MudBlazor; using RestSharp; namespace Indotalent.Features.Thirdparty.CustomerGroup; public class CustomerGroupService : BaseService { private readonly RestClient _client; public CustomerGroupService( IHttpClientFactory clientFactory, NavigationManager nav, ISnackbar snackbar, ICurrentUserService currentUserService, TokenProvider tokenProvider) : base(clientFactory, nav, snackbar, currentUserService, tokenProvider) { _client = new RestClient(nav.BaseUri); } public async Task>?> GetCustomerGroupListAsync() { var request = new RestRequest("api/customer-group", Method.Get); return await ExecuteWithResponseAsync>(_client, request); } public async Task?> GetCustomerGroupByIdAsync(string id) { var request = new RestRequest($"api/customer-group/{id}", Method.Get); return await ExecuteWithResponseAsync(_client, request); } public async Task?> CreateCustomerGroupAsync(CreateCustomerGroupRequest data) { var request = new RestRequest("api/customer-group", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } public async Task DeleteCustomerGroupByIdAsync(string id) { var request = new RestRequest($"api/customer-group/delete/{id}", Method.Post); var response = await ExecuteWithResponseAsync(_client, request); return response?.IsSuccess ?? false; } public async Task?> UpdateCustomerGroupAsync(UpdateCustomerGroupRequest data) { var request = new RestRequest("api/customer-group/update", Method.Post); request.AddJsonBody(data); return await ExecuteWithResponseAsync(_client, request); } }