public ActionResult DeleteGroupIf(string name) { interfaceOperation = true; var group = new DeleteGroupModel { GroupName = name }; return(View(group)); }
public async Task <ActionResult> DeleteGroup([Bind(Include = "name")] DeleteGroupModel model) { ActionResult result = null; await Groups.DeleteGroup(model.Name); result = Redirect(Request.UrlReferrer.ToString()); return(result); }
public IActionResult Delete(string id) { var group = _groupService.GetById(id); var model = new DeleteGroupModel { GroupId = id, Name = group.Name }; return(View(model)); }
public ActionResult DeleteGroup(int GroupId) { var currentUser = idb.Users.Find(User.Identity.GetUserId()); if (!repository.IsGroupCreator(GroupId, currentUser.Id)) { return(RedirectToAction("Index", "Group")); } else { Group CurrentGroup = repository.GetGroupByID(GroupId); DeleteGroupModel _DeleteGroupModel = new DeleteGroupModel { GroupId = GroupId, Name = CurrentGroup.name }; return(View(_DeleteGroupModel)); } }
public ActionResult <GroupModel> DeleteGroupByIf(DeleteGroupModel groupModel) { interfaceOperation = true; var creator = usersApi.FindIdUserByName(groupModel.Creator); var group = groupsApi.FindGroupByName(groupModel.GroupName); if (creator == -1) { return(RedirectToAction(nameof(MessagePage), new { message = "No such user!" })); } var permission = permissionsApi.GetPermissionForUserByGroup(creator, group.Id); if (permission == null) { return(RedirectToAction(nameof(MessagePage), new { message = "No information about permission for this group!" })); } if (permission.Operation != Operation.Admin) { return(RedirectToAction(nameof(MessagePage), new { message = "No admin permission!" })); } var result = groupsApi.DeleteGroup(groupModel.GroupName); return(RedirectToAction(nameof(GetAllGroupsByIf))); }
public async Task <IActionResult> Delete(DeleteGroupModel model) { Group group = await _context.Groups.FindAsync(model.groupid); if (group == null) { return(await RedirectBack($"Could not find the group {model.groupid}")); } User user = await _userManager.GetUserAsync(User); if (user == null) { return(await RedirectBack($"Could not verify user!")); } if (!group.IsOwner(user)) { return(await RedirectBack($"You don't own {group.Name}!")); } // Remove category ForumCategory category = _context.ForumCategories.FirstOrDefault(c => c.CategoryID == group.Name); if (category != null) { _context.ForumCategories.Remove(category); } await _context.SaveChangesAsync(); /* * Stock stock = _stockContext.Stocks.FirstOrDefault(s => s.GroupID == model.groupid); * * // Handle stocks * * if (stock != null) * { * int publicOwners = stock.Total - stock.ExchangeOwned; * * foreach (var ownership in stock.GetAllOwnership()) * { * User stockowner = await _userManager.FindByIdAsync(ownership.Item1); * * decimal ret = ((ownership.Item2 * 1.0m) / publicOwners) * group.Credits; * * stockowner.Credits += ret; * * await _userManager.UpdateAsync(stockowner); * } * * _stockContext.Stocks.Remove(stock); * * await _stockContext.SaveChangesAsync(); * } */ await group.ClearRoles(); _context.Remove(group); await _context.SaveChangesAsync(); StatusMessage = $"Successfully deleted {group.Name}!"; return(RedirectToAction("Index", controllerName: "Home")); }