public async Task <IActionResult> Post([FromBody] GarmentShippingLocalSalesContractViewModel viewModel) { try { VerifyUser(); _validateService.Validate(viewModel); var result = await _service.Create(viewModel); return(Created("/", result)); } catch (ServiceValidationException ex) { var Result = new { error = ResultFormatter.Fail(ex), apiVersion = "1.0.0", statusCode = HttpStatusCode.BadRequest, message = "Data does not pass validation" }; return(new BadRequestObjectResult(Result)); } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } }
public void Validate_DefaultValue() { GarmentShippingLocalSalesContractViewModel viewModel = new GarmentShippingLocalSalesContractViewModel(); var result = viewModel.Validate(null); Assert.NotEmpty(result.ToList()); }