public async Task <IActionResult> CreateExdec([FromBody] CreateExDecDto exDeclarationDto) { if (ModelState.IsValid) { var res = await exDeclarationService.CreateExDec(exDeclarationDto); switch (res) { case ExDeclarationResult.ExDecIsExist: return(JsonResponseStatus.Error(new { Info = "شماره اظهارنامه وارد شده قبلا در سیستم ثبت شده" })); } } return(JsonResponseStatus.Success()); }
public async Task <ExDeclarationResult> CreateExDec(CreateExDecDto exDeclaration) { var isExCodeExist = _exDeclarationRepository.IsCodeExist(exDeclaration.ExCode.Trim().ToLower()); if (isExCodeExist) { return(ExDeclarationResult.ExDecIsExist); } var exDec = new ExDeclaration { ExchangeDeclarationCode = exDeclaration.ExCode.Trim().SanitizeText(), ExprireDate = exDeclaration.ExpireDate, IsSold = false, Price = exDeclaration.Price, Qty = exDeclaration.Qty, Description = exDeclaration.Description.Trim().SanitizeText() }; await _exDeclarationRepository.AddEntity(exDec); await _exDeclarationRepository.SaveChanges(); return(ExDeclarationResult.Success); }