InvMoveController.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using Procurement.Enums;
  2. using Microsoft.AspNetCore.Mvc;
  3. using System;
  4. using System.Threading.Tasks;
  5. using Volo.Abp.AspNetCore.Mvc;
  6. using Procurement.EntityFrameworkCore.SqlRepositories;
  7. using Procurement.ViewModel;
  8. using Procurement.Helpers;
  9. using System.Text.Json;
  10. namespace Procurement.Controllers
  11. {
  12. [Produces("application/json")]
  13. [Route("api/wms/[controller]")]
  14. public class InvMoveController : AbpController
  15. {
  16. private readonly ISqlRepository _repository;
  17. public InvMoveController(ISqlRepository sqlRepository)
  18. {
  19. _repository = sqlRepository;
  20. }
  21. /// <summary>
  22. /// 괏닸盧욋�헝
  23. /// </summary>
  24. /// <returns></returns>
  25. [HttpPost]
  26. public async Task<IActionResult> Post([FromBody] JsonElement jsonElement)
  27. {
  28. if (jsonElement.ValueKind == JsonValueKind.Undefined || jsonElement.ValueKind == JsonValueKind.Null)
  29. {
  30. return BadRequest();
  31. }
  32. ResultCode code = ResultCode.Fail, subCode = ResultCode.Fail;
  33. string subMsg = "";
  34. try
  35. {
  36. string proc = "pr_WMS_SaveInvMove";
  37. SqlParameterViewModel[] sqlParams = await SqlHelper.CreateSqlParameters(_repository, proc, jsonElement);
  38. var resultData = await _repository.GetResultByProcAsync(proc, sqlParams);
  39. subMsg = resultData.msg;
  40. if (resultData.isSuccess)
  41. {
  42. code = ResultCode.Success;
  43. subCode = ResultCode.Success;
  44. }
  45. }
  46. catch (Exception ex)
  47. {
  48. subMsg = ex.Message;
  49. code = ResultCode.Fail;
  50. subCode = ResultCode.Fail;
  51. }
  52. ResultViewModel result = ResultHelper.CreateResult(code, null, subCode, subMsg);
  53. return Ok(result);
  54. }
  55. /// <summary>
  56. /// 괏닸객데딧꺅
  57. /// </summary>
  58. /// <returns></returns>
  59. [Route("bynbr")]
  60. [HttpPost]
  61. public async Task<IActionResult> InvMoveByNbr([FromBody] JsonElement jsonElement)
  62. {
  63. if (jsonElement.ValueKind == JsonValueKind.Undefined || jsonElement.ValueKind == JsonValueKind.Null)
  64. {
  65. return BadRequest();
  66. }
  67. ResultCode code = ResultCode.Fail, subCode = ResultCode.Fail;
  68. string subMsg = "";
  69. try
  70. {
  71. string proc = "pr_WMS_SaveInvMoveByNbr";
  72. SqlParameterViewModel[] sqlParams = await SqlHelper.CreateSqlParameters(_repository, proc, jsonElement);
  73. var resultData = await _repository.GetResultByProcAsync(proc, sqlParams);
  74. subMsg = resultData.msg;
  75. if (resultData.isSuccess)
  76. {
  77. code = ResultCode.Success;
  78. subCode = ResultCode.Success;
  79. }
  80. }
  81. catch (Exception ex)
  82. {
  83. subMsg = ex.Message;
  84. code = ResultCode.Fail;
  85. subCode = ResultCode.Fail;
  86. }
  87. ResultViewModel result = ResultHelper.CreateResult(code, null, subCode, subMsg);
  88. return Ok(result);
  89. }
  90. }
  91. }