示例#1
0
        public ActionResult Delete(int id, AdminRole role)
        {
            try
            {
                DataContext.Delete(role);
                SaveChanges();
                ShowSuccess(MessageResource.DeleteSuccess);

                return RedirectToIndex();
            }
            catch
            {
                ShowError(MessageResource.DeleteFailed);
            }

            return RedirectToIndex();
        }
示例#2
0
        public ActionResult Create(AdminRole model, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.UpdatePermissions(GetPermissions(form));

                    DataContext.AdminRoles.Add(model);
                    SaveChanges();

                    ShowSuccess(MessageResource.CreateSuccess);

                    return RedirectToIndex();
                }
                catch
                {
                    ShowError(MessageResource.CreateFailed);
                }
            }

            return View(model);
        }