public ActionResult LeaveGroup(int Id) { var userService = new UserService(myDbContext); var groupListService = new GroupListService(myDbContext); var userId = User.Identity.GetUserId(); var user = userService.GetUser(userId); var groupList = groupListService.getGroupList(Id, user); groupListService.LeaveGroup(groupList); return(RedirectToAction("Index")); }
public ActionResult JoinGroup(int Id) { var userService = new UserService(myDbContext); var groupListService = new GroupListService(myDbContext); var userId = User.Identity.GetUserId(); var user = userService.GetUser(userId); if (groupListService.getGroupList(Id, user) != null) { return(RedirectToAction("Index")); } var groupList = new GroupList(); var groupService = new GroupService(myDbContext); groupList.Group = groupService.GetGroup(Id); groupList.User = user; groupListService.AddGroupToList(groupList); return(RedirectToAction("Index")); }