public async Task <IActionResult> Post([FromBody] GarmentCorrectionNoteViewModel viewModel)
        {
            try
            {
                identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

                IValidateService validateService = (IValidateService)serviceProvider.GetService(typeof(IValidateService));
                validateService.Validate(viewModel);

                var Model = mapper.Map <GarmentCorrectionNote>(viewModel);

                await facade.Create(Model, identityService.Username);

                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE)
                    .Ok();
                return(Created(String.Concat(Request.Path, "/", 0), Result));
            }
            catch (ServiceValidationExeption e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE)
                    .Fail(e);
                return(BadRequest(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        public void Should_Success_Validate_Data_Koreksi_Harga_Retur()
        {
            GarmentCorrectionNoteViewModel viewModel = new GarmentCorrectionNoteViewModel
            {
                CorrectionType = "Retur",
                DONo           = "DONo",
                Items          = new List <GarmentCorrectionNoteItemViewModel>
                {
                    new GarmentCorrectionNoteItemViewModel
                    {
                        QuantityCheck = 100,
                        Quantity      = 0
                    },
                }
            };

            Assert.True(viewModel.Validate(null).Count() > 0);

            GarmentCorrectionNoteViewModel viewModel2 = new GarmentCorrectionNoteViewModel
            {
                CorrectionType = "Retur",
                DONo           = "DONo",
                Items          = new List <GarmentCorrectionNoteItemViewModel>
                {
                    new GarmentCorrectionNoteItemViewModel
                    {
                        QuantityCheck = 100,
                        Quantity      = 500
                    },
                }
            };

            Assert.True(viewModel2.Validate(null).Count() > 0);
        }
Пример #3
0
        public void Should_Success_Validate_Data_Null_Items()
        {
            GarmentCorrectionNoteViewModel viewModel = new GarmentCorrectionNoteViewModel
            {
                CorrectionType = "Harga Satuan",
                DONo           = "DONo",
            };

            Assert.True(viewModel.Validate(null).Count() > 0);
        }
Пример #4
0
        public void Should_Success_Validate_Data_Koreksi_Harga_Jumlah()
        {
            GarmentCorrectionNoteViewModel viewModel = new GarmentCorrectionNoteViewModel
            {
                CorrectionType = "Jumlah",
                DONo           = "DONo",
                Items          = new List <GarmentCorrectionNoteItemViewModel>
                {
                    new GarmentCorrectionNoteItemViewModel
                    {
                        Quantity = 0
                    },
                }
            };

            Assert.True(viewModel.Validate(null).Count() > 0);
        }
Пример #5
0
        public void Should_Success_Validate_Data_Koreksi_Harga_Total()
        {
            GarmentCorrectionNoteViewModel viewModel = new GarmentCorrectionNoteViewModel
            {
                CorrectionType = "Harga Total",
                DONo           = "DONo",
                Items          = new List <GarmentCorrectionNoteItemViewModel>
                {
                    new GarmentCorrectionNoteItemViewModel
                    {
                        PriceTotalAfter = -1,
                    },
                    new GarmentCorrectionNoteItemViewModel
                    {
                        PriceTotalBefore = 1,
                        PriceTotalAfter  = 1,
                    }
                }
            };

            Assert.True(viewModel.Validate(null).Count() > 0);
        }
        public void Should_Success_Validate_Data_Koreksi_Harga_Jumlah()
        {
            GarmentCorrectionNoteViewModel viewModel = new GarmentCorrectionNoteViewModel
            {
                CorrectionType = "Jumlah",
                DONo           = "DONo",
                Items          = new List <GarmentCorrectionNoteItemViewModel>
                {
                    new GarmentCorrectionNoteItemViewModel
                    {
                        Quantity = 0,

                        DODetailId     = 0,
                        EPOId          = 0,
                        EPONo          = null,
                        PRId           = 0,
                        PRNo           = null,
                        POId           = 0,
                        POSerialNumber = null,
                        RONo           = null,
                        Product        = null,
                        Uom            = null
                    },
                },

                DOId            = 0,
                Currency        = null,
                IncomeTax       = null,
                Remark          = null,
                TotalCorrection = 0,
                NKPH            = null,
                NKPN            = null
            };

            Assert.True(viewModel.Validate(null).Count() > 0);
        }
Пример #7
0
        public void Should_Success_Validate_Data()
        {
            GarmentCorrectionNoteViewModel AllNullViewModel = new GarmentCorrectionNoteViewModel();

            Assert.True(AllNullViewModel.Validate(null).Count() > 0);
        }