60 lines
2.3 KiB
C#
60 lines
2.3 KiB
C#
using Indotalent.ConfigBackEnd.Interfaces;
|
|
using Indotalent.ConfigFrontEnd.Common;
|
|
using Indotalent.Features.Utilities.BookingGroup.Cqrs;
|
|
using Indotalent.Infrastructure.Authentication.Identity;
|
|
using Indotalent.Shared.Models;
|
|
using Microsoft.AspNetCore.Components;
|
|
using MudBlazor;
|
|
using RestSharp;
|
|
|
|
namespace Indotalent.Features.Utilities.BookingGroup;
|
|
|
|
public class BookingGroupService : BaseService
|
|
{
|
|
private readonly RestClient _client;
|
|
|
|
public BookingGroupService(
|
|
IHttpClientFactory clientFactory,
|
|
NavigationManager nav,
|
|
ISnackbar snackbar,
|
|
ICurrentUserService currentUserService,
|
|
TokenProvider tokenProvider)
|
|
: base(clientFactory, nav, snackbar, currentUserService, tokenProvider)
|
|
{
|
|
_client = new RestClient(nav.BaseUri);
|
|
}
|
|
|
|
public async Task<ApiResponse<List<GetBookingGroupListResponse>>?> GetBookingGroupListAsync()
|
|
{
|
|
var request = new RestRequest("api/booking-group", Method.Get);
|
|
return await ExecuteWithResponseAsync<List<GetBookingGroupListResponse>>(_client, request);
|
|
}
|
|
|
|
public async Task<ApiResponse<GetBookingGroupByIdResponse>?> GetBookingGroupByIdAsync(string id)
|
|
{
|
|
var request = new RestRequest($"api/booking-group/{id}", Method.Get);
|
|
return await ExecuteWithResponseAsync<GetBookingGroupByIdResponse>(_client, request);
|
|
}
|
|
|
|
public async Task<ApiResponse<CreateBookingGroupResponse>?> CreateBookingGroupAsync(CreateBookingGroupRequest data)
|
|
{
|
|
var request = new RestRequest("api/booking-group", Method.Post);
|
|
request.AddJsonBody(data);
|
|
return await ExecuteWithResponseAsync<CreateBookingGroupResponse>(_client, request);
|
|
}
|
|
|
|
public async Task<bool> DeleteBookingGroupByIdAsync(string id)
|
|
{
|
|
var request = new RestRequest($"api/booking-group/delete/{id}", Method.Post);
|
|
|
|
var response = await ExecuteWithResponseAsync<object>(_client, request);
|
|
return response?.IsSuccess ?? false;
|
|
}
|
|
|
|
public async Task<ApiResponse<UpdateBookingGroupResponse>?> UpdateBookingGroupAsync(UpdateBookingGroupRequest data)
|
|
{
|
|
var request = new RestRequest("api/booking-group/update", Method.Post);
|
|
request.AddJsonBody(data);
|
|
return await ExecuteWithResponseAsync<UpdateBookingGroupResponse>(_client, request);
|
|
}
|
|
} |