public async Task <IActionResult> Post([FromBody] GarmentShippingLocalPriceCorrectionNoteViewModel 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));
            }
        }
Exemplo n.º 2
0
        public void Validate_DefaultValue()
        {
            GarmentShippingLocalPriceCorrectionNoteViewModel viewModel = new GarmentShippingLocalPriceCorrectionNoteViewModel();

            var result = viewModel.Validate(null);

            Assert.NotEmpty(result.ToList());
        }
Exemplo n.º 3
0
        public void Validate_EmptyValue()
        {
            GarmentShippingLocalPriceCorrectionNoteViewModel viewModel = new GarmentShippingLocalPriceCorrectionNoteViewModel
            {
                salesNote = new GarmentShippingLocalSalesNoteViewModel {
                    Id = 0
                },
                correctionDate = DateTimeOffset.MinValue,
                items          = new List <GarmentShippingLocalPriceCorrectionNoteItemViewModel>()
            };

            var result = viewModel.Validate(null);

            Assert.NotEmpty(result.ToList());
        }
Exemplo n.º 4
0
        public void Validate_ItemsDefaultValue()
        {
            GarmentShippingLocalPriceCorrectionNoteViewModel viewModel = new GarmentShippingLocalPriceCorrectionNoteViewModel();

            viewModel.items = new List <GarmentShippingLocalPriceCorrectionNoteItemViewModel>
            {
                new GarmentShippingLocalPriceCorrectionNoteItemViewModel()
                {
                    isChecked = true
                }
            };

            var result = viewModel.Validate(null);

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