SubscriptionController.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Http;
  3. using Microsoft.AspNetCore.Mvc;
  4. using MTWorkHR.Application.Filters;
  5. using MTWorkHR.Application.Identity;
  6. using MTWorkHR.Application.Models;
  7. using MTWorkHR.Application.Services.Interfaces;
  8. using MTWorkHR.Identity.Services;
  9. namespace MTWorkHR.API.Controllers
  10. {
  11. [Route("api/[controller]")]
  12. [ApiController]
  13. [AppAuthorize]
  14. public class SubscriptionController : ControllerBase
  15. {
  16. private readonly ISubscriptionService _SubscriptionConfigurationService;
  17. public SubscriptionController(ISubscriptionService UserSubscriptionConfigurationService)
  18. {
  19. this._SubscriptionConfigurationService = UserSubscriptionConfigurationService;
  20. }
  21. [HttpGet("GetAll")]
  22. [ProducesResponseType(StatusCodes.Status200OK)]
  23. public async Task<ActionResult<List<SubscriptionConfigurationDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
  24. {
  25. return Ok(await _SubscriptionConfigurationService.GetAll(pagingInput));
  26. }
  27. [HttpGet("Get")]
  28. [ProducesResponseType(StatusCodes.Status200OK)]
  29. public async Task<ActionResult<SubscriptionConfigurationDto>> Get(long SubscriptionConfigurationId)
  30. {
  31. return Ok(await _SubscriptionConfigurationService.GetById(SubscriptionConfigurationId));
  32. }
  33. [HttpPost("Create")]
  34. [ProducesResponseType(StatusCodes.Status200OK)]
  35. [Authorize(Policy = "SuperAdminOnly")]
  36. public async Task<ActionResult<SubscriptionConfigurationDto>> Create([FromBody] SubscriptionConfigurationDto input)
  37. {
  38. return await _SubscriptionConfigurationService.Create(input);
  39. }
  40. [HttpPost("Update")]
  41. [ProducesResponseType(StatusCodes.Status200OK)]
  42. [Authorize(Policy = "SuperAdminOnly")]
  43. public async Task<ActionResult<SubscriptionConfigurationDto>> Update([FromBody] SubscriptionConfigurationDto input)
  44. {
  45. return await _SubscriptionConfigurationService.Update(input);
  46. }
  47. [HttpDelete("Delete")]
  48. [ProducesResponseType(StatusCodes.Status200OK)]
  49. [Authorize(Policy = "SuperAdminOnly")]
  50. public async Task Delete([FromQuery]long id)
  51. {
  52. await _SubscriptionConfigurationService.Delete(id);
  53. }
  54. }
  55. }