Ejemplo n.º 1
0
 private ActionResult Delete(int page, string filter, UserDeleteModel[] list)
 {
     if (ModelState.IsValid)
     {
         try
         {
             foreach (var name in list.Where(x => x.Delete).Select(x => x.Username))
             {
                 this.UserManagementRepository.DeleteUser(name);
             }
             TempData["Message"] = Resources.UserController.UsersDeleted;
             return RedirectToAction("Index", new { page, filter });
         }
         catch (ValidationException ex)
         {
             ModelState.AddModelError("", ex.Message);
         }
         catch
         {
             ModelState.AddModelError("", Resources.UserController.ErrorDeletingUser);
         }
     }
     return Index(page, filter);
 }
Ejemplo n.º 2
0
        public ActionResult Index(int page, string filter, string action, UserDeleteModel[] list)
        {
            if (action == "new") return Create();
            if (action == "delete") return Delete(page, filter, list);

            ModelState.AddModelError("", Resources.UserController.InvalidAction);
            var vm = new UsersViewModel(UserManagementRepository, page, filter);
            return View("Index", vm);
        }