summaryrefslogtreecommitdiff
path: root/Project-Unite/Controllers/GroupsController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Project-Unite/Controllers/GroupsController.cs')
-rw-r--r--Project-Unite/Controllers/GroupsController.cs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/GroupsController.cs b/Project-Unite/Controllers/GroupsController.cs
index 5213349..264b0e6 100644
--- a/Project-Unite/Controllers/GroupsController.cs
+++ b/Project-Unite/Controllers/GroupsController.cs
@@ -30,6 +30,19 @@ namespace Project_Unite.Controllers
return RedirectToAction("ViewGroup", "Groups", new { id = id });
}
+ [Authorize]
+ public ActionResult LeaveGroup()
+ {
+ var db = new ApplicationDbContext();
+ var user = db.Users.FirstOrDefault(x => x.Id == User.Identity.GetUserId());
+ var group = db.Groups.FirstOrDefault(x => x.Id == user.GroupId);
+ if (group == null)
+ return new HttpStatusCodeResult(404);
+ user.GroupId = "";
+ db.SaveChanges();
+ return RedirectToAction("ViewGroup", "Groups", new { id = group.Id });
+
+ }
[Authorize]
public ActionResult ViewGroup(string id)