Esempio n. 1
0
 public ActionResult DeleteConfirmed(int id)
 {
     IAssetRepository repository = new EFAssetRepository(User.Identity.Name);
     Asset asset = repository.Get(id);
     repository.Delete(asset);
     return RedirectToAction("Index");
 }
Esempio n. 2
0
 //
 // 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);
 }
Esempio n. 3
0
        public ActionResult Create(Asset asset)
        {
            IAssetRepository repository = new EFAssetRepository(User.Identity.Name);
            if (ModelState.IsValid)
            {
                repository.Insert(asset);
                return RedirectToAction("Index");
            }

            return View(asset);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        // 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);
        }
Esempio n. 6
0
        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)
        }
Esempio n. 7
0
 //
 // GET: /Asset/
 public ActionResult Index()
 {
     IAssetRepository repository = new EFAssetRepository(User.Identity.Name);
     return View(repository.GetList());
 }