public async Task ActionCreateReportTest() { var optionBuilder = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("testDb04"); var dbContext = new ApplicationDbContext(optionBuilder.Options); var service = new ActionsService(dbContext); var model0 = new LawCase { AbNumber = "13000300401", DebitorId = 11, Date = DateTime.UtcNow.Date, Value = 100, }; dbContext.LawCases.Add(model0); await dbContext.SaveChangesAsync(); var caseAction = new CaseActionsCreateViewModel { Date = DateTime.UtcNow.Date, LawCaseId = 1, }; //await dbContext.CaseActions.AddAsync(caseAction); //await dbContext.SaveChangesAsync(); var result = service.CreateActionReport(caseAction); var x = dbContext.LawCases.Where(x => x.DebitorId == 11).Select(x => x.AbNumber).FirstOrDefault(); Assert.Equal("13000300401", x); Assert.True(result.IsCompletedSuccessfully); }
public IActionResult Application410(int?id) { var viewModel = new CaseActionsCreateViewModel { LawCaseId = (int)id, }; return(View(viewModel)); }
public async Task <IActionResult> Create(CaseActionsCreateViewModel model) { if (ModelState.IsValid) { await this.caseActionsService.CreateAsync(model); return(this.RedirectToAction("All")); } return(this.View(model)); }
public IActionResult Create() { var viewModel = new CaseActionsCreateViewModel { LawCases = this.caseActionsService.GetAllLawCases(), LegalActions = this.caseActionsService.GetAllLegalActions() }; return(this.View(viewModel)); }
public IActionResult CreateActionReport(int lawCaseId, int legalActionId) { var viewModel = new CaseActionsCreateViewModel { Date = DateTime.UtcNow.Date, LawCaseId = lawCaseId, LegalActionId = legalActionId, }; return(this.View(viewModel)); }
//public async Task Application410(CaseActionsCreateViewModel model) //{ // var caseAction = new CaseAction // { // Date = model.Date, // LawCaseId = model.LawCaseId, // LegalActionId = model.LegalActionId, // }; // await this.dbContext.CaseActions.AddAsync(caseAction); // await this.dbContext.SaveChangesAsync(); //} public async Task CreateActionReport(CaseActionsCreateViewModel model) { var caseAction = new CaseAction { Date = model.Date, LawCaseId = model.LawCaseId, LegalActionId = model.LegalActionId, }; await this.dbContext.AddAsync(caseAction); await this.dbContext.SaveChangesAsync(); }
public async Task CaseActionsDeleteTest() { var optionBuilder = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("testDb4"); var dbContext = new ApplicationDbContext(optionBuilder.Options); var service = new CaseActionsService(dbContext); var model = new CaseActionsCreateViewModel { Date = DateTime.UtcNow.Date, }; await service.CreateAsync(model); var result = service.DeleteConfirm(1); Assert.NotNull(result); }
public async Task <IActionResult> CreateActionReport(CaseActionsCreateViewModel model) { if (ModelState.IsValid) { try { await this.actionsService.CreateActionReport(model); return(this.RedirectToAction("AllActions", "Home", new { id = model.LawCaseId })); } catch (Exception ex) { this.ModelState.AddModelError(string.Empty, ex.Message); this.ViewData["Message"] = "Възникна грешка при създаването на запис. Вероятно няма такова действие в базата."; } } return(this.View(model)); }
public async Task CaseActionsEditTest() { var optionBuilder = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("testDb2"); var dbContext = new ApplicationDbContext(optionBuilder.Options); var service = new CaseActionsService(dbContext); var model = new CaseActionsCreateViewModel { Date = DateTime.UtcNow.Date, }; await service.CreateAsync(model); var edited = new CaseActionsEditViewModel { Date = DateTime.UtcNow.Date.AddDays(10), }; var result = service.EditAsync(edited); Assert.NotNull(result); }