Exemple #1
0
        public ActionResult Create(RoleViewModel roleModel)
        {
            if (!ModelState.IsValid || roleModel == null || roleModel.NewName == null ||roleModel.NewName == "")
            {
                return RedirectToAction("Index", new { resultMessage = String.Format("Role {0} could not be created.", roleModel.NewName) });
            }

            try
            {
                if (_adapter.SaveRole(roleModel))
                {
                    return RedirectToAction("Index", new { resultMessage = String.Format("Role {0} created.", roleModel.NewName) });

                }
                return RedirectToAction("Index", new { resultMessage = String.Format("Role {0} could not be created.", roleModel.NewName) });

            }
            catch
            {
                return View();
            }
        }
Exemple #2
0
        public ActionResult Delete(RoleViewModel model)
        {
            if (!ModelState.IsValid) return View(model);
            if (model == null || model.CurrentName == null || model.CurrentName == "")
            {
                return RedirectToAction("Index", new { resultMessage = String.Format("Role {0} could not be deleted.", model.CurrentName) });
            }

            try
            {
                var result = _adapter.removeRole(model);

                if (result)
                {
                    return RedirectToAction("Index", new { resultMessage = String.Format("Role {0} removed.", model.CurrentName) });
                }

                return RedirectToAction("Index", new { resultMessage = String.Format("Role {0} not found.", model.CurrentName) });
            }
            catch
            {
                return View(model);
            }
        }