202 lines
7.4 KiB
C#
202 lines
7.4 KiB
C#
using CPRNIMS.Domain.UIContracts.Account;
|
|
using CPRNIMS.Domain.UIContracts.Receiving;
|
|
using CPRNIMS.Infrastructure.Helper;
|
|
using CPRNIMS.Infrastructure.ViewModel.PR;
|
|
using CPRNIMS.Infrastructure.ViewModel.Receiving;
|
|
using CPRNIMS.WebApps.Controllers.Base;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace CPRNIMS.WebApps.Controllers.Receiving
|
|
{
|
|
public class ReceivingController : BaseMethod
|
|
{
|
|
List<ReceivingVM>? response;
|
|
private readonly IReceiving _receiving;
|
|
private readonly IConfiguration _configuration;
|
|
public ReceivingController(ErrorLogHelper errorMessageService,
|
|
IWebHostEnvironment webHostEnvironment,TokenHelper tokenHelper
|
|
, IReceiving receiving, IConfiguration configuration,IAccount account)
|
|
: base(errorMessageService, webHostEnvironment,tokenHelper, account)
|
|
{
|
|
_receiving = receiving;
|
|
_configuration = configuration;
|
|
}
|
|
#region Get
|
|
public async Task<IActionResult> GetRRReport(ReceivingVM viewModels)
|
|
{
|
|
response = await _receiving.GetRRReport(GetUser(), viewModels);
|
|
|
|
return GetResponse(response);
|
|
}
|
|
public async Task<IActionResult> GetPRDetailByPRNo(ReceivingVM viewModels)
|
|
{
|
|
response = await _receiving.GetPRDetailByPRNo(GetUser(), viewModels);
|
|
|
|
return GetResponse(response);
|
|
}
|
|
public async Task<IActionResult> GetForReceiving()
|
|
{
|
|
var viewModels = new ReceivingVM();
|
|
response = await _receiving.GetForReceiving(GetUser(), viewModels);
|
|
return GetResponse(response);
|
|
}
|
|
public async Task<IActionResult> GetDeniedItem(ReceivingVM viewModels)
|
|
{
|
|
response = await _receiving.GetForReceiving(GetUser(), viewModels);
|
|
return GetResponse(response);
|
|
}
|
|
public async Task<IActionResult> GetRRDetailByPO(ReceivingVM viewModel)
|
|
{
|
|
response = await _receiving.GetRRDetailByPO(GetUser(), viewModel);
|
|
return GetResponse(response);
|
|
}
|
|
public async Task<IActionResult> GetRR(ReceivingVM viewModel)
|
|
{
|
|
response = await _receiving.GetRR(GetUser(), viewModel);
|
|
return GetResponse(response);
|
|
}
|
|
public async Task<IActionResult> GetLatestRRNo(ReceivingVM viewModel)
|
|
{
|
|
response = await _receiving.GetLatestRRNo(GetUser(), viewModel);
|
|
return GetResponse(response);
|
|
}
|
|
public async Task<IActionResult> GetRRDetail(ReceivingVM viewModel)
|
|
{
|
|
response = await _receiving.GetRRDetail(GetUser(), viewModel);
|
|
return GetResponse(response);
|
|
}
|
|
#endregion
|
|
#region POST PUT
|
|
public async Task<IActionResult> PutPOClose(ReceivingVM viewModel, List<ItemReceivingList> ItemList)
|
|
{
|
|
try
|
|
{
|
|
if (ItemList.Count > 0)
|
|
{
|
|
viewModel.ItemList = new ItemReceivingList
|
|
{
|
|
PRDetailsId = ItemList.SelectMany(ic => ic.PRDetailsId).ToList(),
|
|
};
|
|
var postPutItem = await _receiving.PutPOClose(GetUser(), viewModel);
|
|
|
|
if (postPutItem.messCode !=0)
|
|
{
|
|
return Json(new { success = true });
|
|
}
|
|
|
|
return Json(new { success = false, Response = postPutItem.Message });
|
|
}
|
|
return Json(new { success = false, Response = "EmptyArray" });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var message = ex.InnerException?.ToString() ?? ex.Message.ToString();
|
|
throw;
|
|
}
|
|
}
|
|
public async Task<IActionResult> PostPutReceiving(ReceivingVM viewModel, List<ItemReceivingList> ItemList)
|
|
{
|
|
try
|
|
{
|
|
if (ItemList.Count > 0)
|
|
{
|
|
viewModel.ItemList = new ItemReceivingList
|
|
{
|
|
PRDetailsId = ItemList.SelectMany(ic => ic.PRDetailsId).ToList(),
|
|
QuantityReceived = ItemList.SelectMany(ic => ic.QuantityReceived).ToList(),
|
|
};
|
|
var postPutItem = await _receiving.PostPutReceiving(GetUser(), viewModel);
|
|
|
|
if (postPutItem.ErrCode != 0)
|
|
{
|
|
return Json(new { success = true });
|
|
}
|
|
|
|
return Json(new { success = false, Response = postPutItem.ErrMessage });
|
|
}
|
|
return Json(new { success = false, Response = "EmptyArray" });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var message = ex.InnerException?.ToString() ?? ex.Message.ToString();
|
|
throw;
|
|
}
|
|
}
|
|
public async Task<IActionResult> PostPutDeniedItem(ReceivingVM viewModel, List<ItemReceivingList> ItemList)
|
|
{
|
|
try
|
|
{
|
|
if (ItemList.Count > 0)
|
|
{
|
|
viewModel.ItemList = new ItemReceivingList
|
|
{
|
|
PRDetailsId = ItemList.SelectMany(ic => ic.PRDetailsId).ToList(),
|
|
PRNo = ItemList.SelectMany(ic => ic.PRNo).ToList(),
|
|
ItemNo = ItemList.SelectMany(ic => ic.ItemNo).ToList(),
|
|
};
|
|
var postPutItem = await _receiving.PostPutDeniedItem(GetUser(), viewModel);
|
|
|
|
if (postPutItem.StatusResponse != "Error")
|
|
{
|
|
return Json(new { success = true });
|
|
}
|
|
|
|
return Json(new { success = false, Response = postPutItem.Message });
|
|
}
|
|
return Json(new { success = false, Response = "EmptyArray" });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var message = ex.InnerException?.ToString() ?? ex.Message.ToString();
|
|
throw;
|
|
}
|
|
}
|
|
public async Task<IActionResult> PutRRNoSeries(ReceivingVM viewModel)
|
|
{
|
|
try
|
|
{
|
|
var postPutItem = await _receiving.PutRRNoSeries(GetUser(), viewModel);
|
|
|
|
if (postPutItem.StatusResponse != "Error")
|
|
{
|
|
return Json(new { success = true });
|
|
}
|
|
|
|
return Json(new { success = false, Response = postPutItem.Message });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var message = ex.InnerException?.ToString() ?? ex.Message.ToString();
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
#region Views
|
|
public async Task<IActionResult> RRReport()
|
|
{
|
|
return await IsAuthenTicated();
|
|
}
|
|
public async Task<IActionResult> Index()
|
|
{
|
|
return await IsAuthenTicated();
|
|
}
|
|
public async Task<IActionResult> RRArchived()
|
|
{
|
|
return await IsAuthenTicated();
|
|
}
|
|
public async Task<IActionResult> DeniedItem()
|
|
{
|
|
return await IsAuthenTicated();
|
|
}
|
|
public IActionResult GetRRTable(int id)
|
|
{
|
|
return ViewComponent("RRTable", new { tableId = id });
|
|
}
|
|
public IActionResult GetRRBody(int id)
|
|
{
|
|
return ViewComponent("RRBody", new { tableId = id });
|
|
}
|
|
#endregion
|
|
}
|
|
}
|