public ActionResult Delete(long[] ids) { ProjectContext.DeleteIterations(ids); Context.SaveChanges(); if (ProjectContext.Errors.Any()) { AddModelErrors(ProjectContext.Errors); } var model = new DeleteModel { Ids = ids, Message = string.Empty, Controller = "Iteration" }; return JsonView(ModelState.IsValid && !ProjectContext.Errors.Any(), "_DeleteModal", model); }
public ActionResult Delete(long id) { User user; if (!Context.Users.TryGetById(id, out user)) throw new InvalidOperationException("The User you are trying to delete does not exist."); var resourceManager = new ResourceManager(typeof(Localized)); var message = resourceManager.GetString("AreYouSureYouWantToDelete"); var model = new DeleteModel { Ids = new[] { id }, Message = string.Format("{0} {1}?", message, user.Name), Controller = "User" }; return PartialView("_DeleteModal", model); }
public ActionResult Delete(long[] ids) { if (ids.Contains(WebSecurity.CurrentUserId)) { AddModelError(string.Empty, "CannotDeleteYourOwnUser"); } var idsToDelete = ids.Where(x => x != WebSecurity.CurrentUserId).ToArray(); Context.DeleteUsers(idsToDelete); Context.SaveChanges(); if (Context.Errors.Any()) { AddModelErrors(Context.Errors); } var model = new DeleteModel { Ids = ids, Message = string.Empty, Controller = "User" }; return JsonView(ModelState.IsValid && !Context.Errors.Any(), "_DeleteModal", model); }
public ActionResult Delete(long id) { Issue issue; if (!ProjectContext.Issues.TryGetById(id, out issue)) throw new InvalidOperationException("The Issue you are trying to delete does not exist."); var resourceManager = new ResourceManager(typeof(Localized)); var message = resourceManager.GetString("AreYouSureYouWantToDelete"); var model = new DeleteModel { Ids = new[] { id }, Message = string.Format("{0} {1}?", message, issue.Summary), Controller = "Backlog" }; return PartialView("_DeleteModal", model); }