Esempio n. 1
0
        public async Task Should_Success_Create_Data()
        {
            PurchasingToVerificationViewModel viewModel = new PurchasingToVerificationViewModel()
            {
                UnitPaymentOrders = new List <UnitPaymentOrderViewModel>()
                {
                    new UnitPaymentOrderViewModel()
                    {
                        No           = Guid.NewGuid().ToString(),
                        Currency     = "IDR",
                        DivisionCode = "Division",
                        DivisionName = "Division",
                        SupplierCode = "Supplier",
                        SupplierName = "Supplier",
                        DueDate      = DateTimeOffset.UtcNow,
                        InvoiceNo    = "Invoice",
                        TotalPaid    = 1000000,
                        UPODate      = DateTimeOffset.UtcNow,
                    }
                }
            };

            var response = await Client.PostAsync(URI, new StringContent(JsonConvert.SerializeObject(viewModel).ToString(), Encoding.UTF8, MediaType));

            Assert.Equal(HttpStatusCode.Created, response.StatusCode);
        }
Esempio n. 2
0
        public async Task <ActionResult> Post([FromBody] PurchasingToVerificationViewModel viewModel)
        {
            this.identityService.Token    = Request.Headers["Authorization"].First().Replace("Bearer ", "");
            this.identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

            ValidateService validateService = (ValidateService)purchasingDocumentExpeditionFacade.serviceProvider.GetService(typeof(ValidateService));

            try
            {
                validateService.Validate(viewModel);

                object model = viewModel.ToModel();

                await purchasingDocumentExpeditionFacade.SendToVerification(model, this.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));
            }
        }
Esempio n. 3
0
        public async Task Should_Success_Create_Data()
        {
            PurchasingToVerificationViewModel viewModel = new PurchasingToVerificationViewModel()
            {
                UnitPaymentOrders = new List <UnitPaymentOrderViewModel>()
                {
                    new UnitPaymentOrderViewModel()
                    {
                        No            = Guid.NewGuid().ToString(),
                        Currency      = "IDR",
                        DivisionCode  = "Division",
                        DivisionName  = "Division",
                        CategoryCode  = "Category",
                        CategoryName  = "Category",
                        SupplierCode  = "Supplier",
                        SupplierName  = "Supplier",
                        DueDate       = DateTimeOffset.UtcNow,
                        InvoiceNo     = "Invoice",
                        IncomeTax     = 1,
                        IncomeTaxId   = "IncomeTaxId",
                        IncomeTaxName = "PPH",
                        IncomeTaxRate = 1,
                        Vat           = 500,
                        TotalPaid     = 1000000,
                        UPODate       = DateTimeOffset.UtcNow,
                        Items         = new List <UnitPaymentOrderItemViewModel>()
                        {
                            new UnitPaymentOrderItemViewModel()
                            {
                                ProductId   = "ProductId",
                                ProductCode = "ProductCode",
                                ProductName = "ProductName",
                                Price       = 5000,
                                Quantity    = 5,
                                UnitId      = "UnitId",
                                UnitCode    = "UnitCode",
                                UnitName    = "UnitName",
                                Uom         = "MTR"
                            }
                        }
                    }
                }
            };

            var response = await Client.PostAsync(URI, new StringContent(JsonConvert.SerializeObject(viewModel).ToString(), Encoding.UTF8, MediaType));

            Assert.Equal(HttpStatusCode.Created, response.StatusCode);
        }