Пример #1
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] GarmentPackingListUnitPackingViewModel viewModel)
        {
            try
            {
                VerifyUser();
                _validateService.Validate(viewModel);
                var result = await _service.Update(id, viewModel);

                return(Ok(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));
            }
        }
Пример #2
0
        public void Validate_DefaultValue()
        {
            GarmentPackingListUnitPackingViewModel viewModel = ViewModel;

            var result = viewModel.Validate(null);

            Assert.NotEmpty(result.ToList());
        }
Пример #3
0
        public void Validate_Items_Empty()
        {
            GarmentPackingListUnitPackingViewModel viewModel = ViewModel;

            viewModel.Mode  = Mode.CREATE;
            viewModel.Items = null;

            var result = viewModel.Validate(null);

            Assert.NotEmpty(result.ToList());
        }