Esempio n. 1
0
        public ActionResult AddAccu(AccuViewModel model)
        {
            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }

            new Accu().AddAccu(new Accu(model.Name, GetCurrentUserId(), model.Specs));

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 2
0
        public ActionResult UpdateAccu(AccuViewModel model)
        {
            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var accu = new Accu(model.Id, model.Name, model.CreatorId, model.Specs);

            if (new Accu().UpdateAccu(accu))
            {
                return(RedirectToAction("AccuView", new { id = model.Id }));
            }

            ModelState.AddModelError("", "Something went wrong while trying to connect to the database ");
            return(View(model));
        }
Esempio n. 3
0
        public IActionResult UpdateAccu(int id)
        {
            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }
            var selectedAccu = new Accu().GetAccuById(id);

            if (selectedAccu != null)
            {
                var model = new AccuViewModel()
                {
                    Id          = id, Name = selectedAccu.Name, Specs = selectedAccu.Specs, CreatorId = selectedAccu.Creator.Id,
                    CreatorName = selectedAccu.Creator.Username
                };
                return(View(model));
            }
            ModelState.AddModelError("", "Something went wrong while trying to connect to the database ");
            return(RedirectToAction("AccuView", new { id = id }));
        }