예제 #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 async Task <IActionResult> Edit(LawCaseViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(this.View(model));
            }
            await this.lawCaseService.EditAsync(model);

            return(this.RedirectToAction("All"));
        }
예제 #3
0
        //public async Task<LawCaseViewModel> EditAsync(int? id)
        //{
        //    return await this.dbContext.LawCases.Where(x => x.Id == id).Select(l => new LawCaseViewModel
        //    {
        //        Id = l.Id,
        //        Date = l.Date,
        //        AbNumber = l.AbNumber,
        //        DebitorId = l.DebitorId,
        //        MoratoriumInterest = l.MoratoriumInterest,
        //        LegalInterest = l.LegalInterest,
        //        Value = l.Value,
        //        PeriodFrom = l.PeriodFrom,
        //        PeriodTo = l.PeriodTo,
        //        InvoiceCount = l.InvoiceCount,
        //    }).FirstOrDefaultAsync();
        //}

        public async Task EditAsync(LawCaseViewModel model)
        {
            var lawCase = new LawCase
            {
                Id                 = model.Id,
                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,
            };

            this.dbContext.Update(lawCase);
            await this.dbContext.SaveChangesAsync();
        }