コード例 #1
0
        public async Task ExecutorCasessEditTest()
        {
            var optionBuilder = new DbContextOptionsBuilder <ApplicationDbContext>()
                                .UseInMemoryDatabase("testDb2");
            var dbContext = new ApplicationDbContext(optionBuilder.Options);

            var service = new LawCaseService(dbContext);

            var lawCase = new LawCaseInputModel
            {
                Date               = DateTime.UtcNow.Date,
                InvoiceCount       = 5,
                MoratoriumInterest = 15.3m,
                Value              = 100,
                PeriodFrom         = DateTime.UtcNow.Date.AddMonths(-3),
                PeriodTo           = DateTime.UtcNow.Date.AddMonths(-2)
            };

            await service.CreateAsync(lawCase);

            var lawCaseEdit = new LawCaseViewModel
            {
                Date               = DateTime.UtcNow.Date.AddDays(3),
                InvoiceCount       = 6,
                MoratoriumInterest = 15.3m,
                Value              = 102,
                PeriodFrom         = DateTime.UtcNow.Date.AddMonths(-3),
                PeriodTo           = DateTime.UtcNow.Date.AddMonths(-2)
            };

            var result = service.EditAsync(lawCaseEdit);

            Assert.NotNull(result);
            //Assert.Equal(2, result.Id);
        }
コード例 #2
0
        public IActionResult Create()
        {
            var viewModel = new LawCaseInputModel
            {
                AbNumbers = this.lawCaseService.AbNumbers(),
                Debitors  = this.lawCaseService.Debitors()
            };

            return(this.View(viewModel));
        }
コード例 #3
0
        public async Task <IActionResult> Create(LawCaseInputModel model)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new LawCaseInputModel
                {
                    AbNumbers = this.lawCaseService.AbNumbers(),
                    Debitors  = this.lawCaseService.Debitors()
                };
                return(this.View(viewModel));
            }
            await this.lawCaseService.CreateAsync(model);

            return(this.RedirectToAction("All"));
        }
コード例 #4
0
        public async Task CreateAsync(LawCaseInputModel model)
        {
            var lawCase = new LawCase
            {
                Date               = model.Date,
                AbNumber           = model.AbNumber,
                DebitorId          = model.DebitorId,
                MoratoriumInterest = model.MoratoriumInterest,
                LegalInterest      = model.LegalInterest,
                Value              = model.Value,
                PeriodFrom         = model.PeriodFrom,
                PeriodTo           = model.PeriodTo,
                InvoiceCount       = model.InvoiceCount,
            };

            await this.dbContext.LawCases.AddAsync(lawCase);

            await this.dbContext.SaveChangesAsync();
        }