示例#1
0
        public async Task Should_Success_Post_Data()
        {
            var serviceProviderMock = GetServiceProvider();
            var dbContext           = GetDbContext(GetCurrentMethod());

            var service = new GarmentInvoicePurchasingDispositionService(serviceProviderMock.Object, dbContext);

            var expedition = new GarmentDispositionExpeditionModel();

            EntityExtension.FlagForCreate(expedition, "Test", "Test");
            dbContext.GarmentDispositionExpeditions.Add(expedition);
            dbContext.SaveChanges();

            var model = new GarmentInvoicePurchasingDispositionPostingViewModel()
            {
                ListIds = new List <GarmentInvoicePurchasingDispositionPostingIdViewModel>()
                {
                    new GarmentInvoicePurchasingDispositionPostingIdViewModel()
                    {
                        Id = 1
                    }
                }
            };

            var result = await service.Post(model);

            Assert.Equal(0, result);
        }
        public async Task <int> Post(GarmentInvoicePurchasingDispositionPostingViewModel form)
        {
            List <int> listIds = form.ListIds.Select(x => x.Id).ToList();

            foreach (int id in listIds)
            {
                var model = await ReadByIdAsync(id);

                if (model != null)
                {
                    model.SetIsPosted(IdentityService.Username, UserAgent);

                    foreach (var item in model.Items)
                    {
                        await SetTrueDisposition(item.DispositionNo);
                    }

                    await _autoDailyBankTransactionService.AutoCreateFromGarmentInvoicePurchasingDisposition(model);
                }
            }

            var result = await DbContext.SaveChangesAsync();

            return(result);
        }
        public void Shoul_Success_Build_Garment_Invoice_Disposition_Posting()
        {
            var vm = new GarmentInvoicePurchasingDispositionPostingViewModel()
            {
                ListIds = new List <GarmentInvoicePurchasingDispositionPostingIdViewModel>()
            };

            Assert.NotNull(vm.ListIds);
        }
        public async Task <IActionResult> PaymentDispositionNotePost([FromBody] GarmentInvoicePurchasingDispositionPostingViewModel form)
        {
            try
            {
                VerifyUser();
                var result = await Service.Post(form);

                return(Ok(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));
            }
        }