public ActionResult DeleteConfirmed(int id) { IAssetRepository repository = new EFAssetRepository(User.Identity.Name); Asset asset = repository.Get(id); repository.Delete(asset); return RedirectToAction("Index"); }
// // GET: /Asset/Edit/5 public ActionResult Edit(int id = 0) { IAssetRepository repository = new EFAssetRepository(User.Identity.Name); Asset asset = repository.Get(id); if (asset == null) { return HttpNotFound(); } return View(asset); }
public ActionResult Create(Asset asset) { IAssetRepository repository = new EFAssetRepository(User.Identity.Name); if (ModelState.IsValid) { repository.Insert(asset); return RedirectToAction("Index"); } return View(asset); }
public ActionResult Year(int year) { ViewBag.PreviousYear = year - 1; ViewBag.Year = year; ViewBag.NextYear = year + 1; ViewBag.DecadeStartYear = year / 10 * 10; ViewBag.DecadeEndYear = year / 10 * 10 + 9; IAssetRepository assetRepository = new EFAssetRepository(User.Identity.Name); ICreditRepository creditRepository = new EFCreditRepository(User.Identity.Name); ProjectionGenerator generator = new ProjectionGenerator(assetRepository, creditRepository); List<DateTime> dateList = new List<DateTime>(); for (int m = 1; m <= 12; m++) { dateList.Add(new DateTime(year, m, 1)); } ProjectionViewModel viewModel = generator.GenerateProjection(dateList, false); return View(viewModel); }
// year = start year public ActionResult Decade(int year) { ViewBag.PreviousYearStart = year - 10; ViewBag.PreviousYearEnd = year - 1; ViewBag.YearStart = year; ViewBag.YearEnd = year + 9; ViewBag.NextYearStart = year + 10; ViewBag.NextYearEnd = year + 19; IAssetRepository assetRepository = new EFAssetRepository(User.Identity.Name); ICreditRepository creditRepository = new EFCreditRepository(User.Identity.Name); ProjectionGenerator generator = new ProjectionGenerator(assetRepository, creditRepository); List<DateTime> dateList = new List<DateTime>(); for (int y = year; y < year + 10; y++) { dateList.Add(new DateTime(y, 1, 1)); } ProjectionViewModel viewModel = generator.GenerateProjection(dateList, true); return View(viewModel); }
public void MultiUserTest() { // Start with anonymous user IAssetRepository repository = new EFAssetRepository(null); // Add records // Check they are there // Set user to 'user1' // Check no records // Add records // Check they are there // Set user to 'user2' // Check no records // Add records // Check they are there // Set user to 'user1' // Check it's the correct records // Set to anonymous user // Check it's the correct records // (Could attempt to access anothers records using the url to check security) }
// // GET: /Asset/ public ActionResult Index() { IAssetRepository repository = new EFAssetRepository(User.Identity.Name); return View(repository.GetList()); }