summaryrefslogtreecommitdiff
path: root/Project-Unite/Controllers/GroupsController.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-07 09:37:41 -0400
committerMichael <[email protected]>2017-05-07 09:37:41 -0400
commite6c0552be8363a597d2427c2ef1fcb73672ed6e1 (patch)
treeb1b2c072fdab88043cf8ff5e3141aa97daaf9ef3 /Project-Unite/Controllers/GroupsController.cs
parent8e6196fd1d6b072ae14451a2119062e3401d1523 (diff)
downloadproject-unite-e6c0552be8363a597d2427c2ef1fcb73672ed6e1.tar.gz
project-unite-e6c0552be8363a597d2427c2ef1fcb73672ed6e1.tar.bz2
project-unite-e6c0552be8363a597d2427c2ef1fcb73672ed6e1.zip
LeaveGroup action
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)