using Application.Features.CustomerGroupManager.Commands; using Application.Features.CustomerGroupManager.Queries; using ASPNET.BackEnd.Common.Base; using ASPNET.BackEnd.Common.Models; using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace ASPNET.BackEnd.Controllers; [Route("api/[controller]")] public class CustomerGroupController : BaseApiController { public CustomerGroupController(ISender sender) : base(sender) { } [Authorize] [HttpPost("CreateCustomerGroup")] public async Task>> CreateCustomerGroupAsync(CreateCustomerGroupRequest request, CancellationToken cancellationToken) { var response = await _sender.Send(request, cancellationToken); return Ok(new ApiSuccessResult { Code = StatusCodes.Status200OK, Message = $"Success executing {nameof(CreateCustomerGroupAsync)}", Content = response }); } [Authorize] [HttpPost("UpdateCustomerGroup")] public async Task>> UpdateCustomerGroupAsync(UpdateCustomerGroupRequest request, CancellationToken cancellationToken) { var response = await _sender.Send(request, cancellationToken); return Ok(new ApiSuccessResult { Code = StatusCodes.Status200OK, Message = $"Success executing {nameof(UpdateCustomerGroupAsync)}", Content = response }); } [Authorize] [HttpPost("DeleteCustomerGroup")] public async Task>> DeleteCustomerGroupAsync(DeleteCustomerGroupRequest request, CancellationToken cancellationToken) { var response = await _sender.Send(request, cancellationToken); return Ok(new ApiSuccessResult { Code = StatusCodes.Status200OK, Message = $"Success executing {nameof(DeleteCustomerGroupAsync)}", Content = response }); } [Authorize] [HttpGet("GetCustomerGroupList")] public async Task>> GetCustomerGroupListAsync( CancellationToken cancellationToken, [FromQuery] bool isDeleted = false ) { var request = new GetCustomerGroupListRequest { IsDeleted = isDeleted }; var response = await _sender.Send(request, cancellationToken); return Ok(new ApiSuccessResult { Code = StatusCodes.Status200OK, Message = $"Success executing {nameof(GetCustomerGroupListAsync)}", Content = response }); } }