public void Validate_ItemsEmptyValue()
        {
            GarmentShippingPaymentDispositionViewModel viewModel = new GarmentShippingPaymentDispositionViewModel();

            viewModel.paymentType    = "FORWARDER";
            viewModel.invoiceDetails = new List <GarmentShippingPaymentDispositionInvoiceDetailViewModel>
            {
                new GarmentShippingPaymentDispositionInvoiceDetailViewModel
                {
                    invoiceId = 0,
                    invoiceNo = ""
                }
            };
            viewModel.billDetails = new List <GarmentShippingPaymentDispositionBillDetailViewModel>
            {
                new GarmentShippingPaymentDispositionBillDetailViewModel
                {
                    billDescription = "",
                    amount          = 0
                }
            };

            var result = viewModel.Validate(null);

            Assert.NotEmpty(result.ToList());
        }
Exemple #2
0
        public async Task <IActionResult> Post([FromBody] GarmentShippingPaymentDispositionViewModel 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()
        {
            GarmentShippingPaymentDispositionViewModel viewModel = new GarmentShippingPaymentDispositionViewModel();

            var result = viewModel.Validate(null);

            Assert.NotEmpty(result.ToList());
        }
        public void Validate_EmptyValue()
        {
            GarmentShippingPaymentDispositionViewModel viewModel = new GarmentShippingPaymentDispositionViewModel
            {
                paymentType = "EMKL",
                emkl        = new EMKL {
                    Id = 0
                },
                buyerAgent = new BuyerAgent {
                    Id = 0
                },
                incomeTax = new IncomeTax {
                    id = 0
                }
            };

            var result = viewModel.Validate(null);

            Assert.NotEmpty(result.ToList());

            GarmentShippingPaymentDispositionViewModel viewModel2 = new GarmentShippingPaymentDispositionViewModel
            {
                paymentType = "FORWARDER",
                forwarder   = new Forwarder {
                    id = 0
                },
                buyerAgent = new BuyerAgent {
                    Id = 0
                },
                incomeTax = new IncomeTax {
                    id = 0
                }
            };

            var result2 = viewModel2.Validate(null);

            Assert.NotEmpty(result2.ToList());

            GarmentShippingPaymentDispositionViewModel viewModel3 = new GarmentShippingPaymentDispositionViewModel
            {
                paymentType = "COURIER",
                forwarder   = new Forwarder {
                    id = 0
                },
                buyerAgent = new BuyerAgent {
                    Id = 0
                },
                incomeTax = new IncomeTax {
                    id = 0
                }
            };

            var result3 = viewModel3.Validate(null);

            Assert.NotEmpty(result3.ToList());
        }
        public void Validate_ItemsDefaultValue()
        {
            GarmentShippingPaymentDispositionViewModel viewModel = new GarmentShippingPaymentDispositionViewModel();

            viewModel.paymentType      = "FORWARDER";
            viewModel.isFreightCharged = true;
            viewModel.billDetails      = new List <GarmentShippingPaymentDispositionBillDetailViewModel>
            {
                new GarmentShippingPaymentDispositionBillDetailViewModel()
            };
            viewModel.invoiceDetails = new List <GarmentShippingPaymentDispositionInvoiceDetailViewModel>
            {
                new GarmentShippingPaymentDispositionInvoiceDetailViewModel()
            };

            var result = viewModel.Validate(null);

            Assert.NotEmpty(result.ToList());


            viewModel.paymentType = "EMKL";
            viewModel.billDetails = new List <GarmentShippingPaymentDispositionBillDetailViewModel>
            {
                new GarmentShippingPaymentDispositionBillDetailViewModel()
            };
            viewModel.invoiceDetails = new List <GarmentShippingPaymentDispositionInvoiceDetailViewModel>
            {
                new GarmentShippingPaymentDispositionInvoiceDetailViewModel()
            };

            var result2 = viewModel.Validate(null);

            Assert.NotEmpty(result2.ToList());


            viewModel.paymentType = "COURIER";
            viewModel.totalBill   = 1000;
            viewModel.billDetails = new List <GarmentShippingPaymentDispositionBillDetailViewModel>
            {
                new GarmentShippingPaymentDispositionBillDetailViewModel()
            };
            viewModel.unitCharges = new List <GarmentShippingPaymentDispositionUnitChargeViewModel>
            {
                new GarmentShippingPaymentDispositionUnitChargeViewModel()
            };

            var result3 = viewModel.Validate(null);

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