using CPRNIMS.Domain.Contracts.Finance; using CPRNIMS.Domain.Services; using CPRNIMS.Infrastructure.Dto.Finance; using CPRNIMS.Infrastructure.Dto.Items; using CPRNIMS.Infrastructure.Dto.SMTP; using CPRNIMS.Infrastructure.Helper; using CPRNIMS.Infrastructure.ViewModel.Common; using CPRNIMS.Infrastructure.ViewModel.PR; using CPRNIMS.WebApi.Controllers.Base; using Microsoft.AspNetCore.Mvc; using System.Text; namespace CPRNIMS.WebApi.Controllers.Finance { public class RRMgmtController : BaseController { private readonly IRR _rr; public RRMgmtController(ErrorMessageService errorMessageService, IWebHostEnvironment webHostEnvironment, IConfiguration configuration, IRR rr) : base(errorMessageService, webHostEnvironment, configuration) { _rr = rr; } #region Get [HttpPost("GetAllClosedPO")] public async Task GetAllClosedPO(RRDetailsDto itemCodeDto) { var allPR = await _rr.GetAllClosedPO(itemCodeDto); return Ok(allPR); } [HttpPost("GetRRDetailByPO")] public async Task GetRRDetailByPO(RRDetailsDto itemDto) { var myPR = await _rr.GetRRDetailByPO(itemDto); return Ok(myPR); } #endregion #region Post Put [HttpPost("PostPutPayment")] public async Task PostPutPayment([FromBody] PRVM viewModel) { try { foreach (var items in viewModel.ItemList.PRDetailsId) { var index = viewModel.ItemList.PRDetailsId.IndexOf(items); var rrDto = new RRDetailsDto { UserId = viewModel.UserId, PONo = viewModel.PONo, POTypeId = viewModel.POTypeId, PRDetailsId = viewModel.ItemList.PRDetailsId[index], }; var pR = await _rr.PostPutPayment(rrDto); } return Ok(new { success = true }); } catch (Exception ex) { var errorMessage = ex.InnerException?.ToString() ?? ex.Message.ToString(); await PostErrorMessage(errorMessage + "PostPutPayment", "WebApi"); throw; } } #endregion } }