diff options
| author | Michael <[email protected]> | 2017-05-07 09:36:02 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-07 09:36:02 -0400 |
| commit | 8e6196fd1d6b072ae14451a2119062e3401d1523 (patch) | |
| tree | 6b45dcdae9429c53df581bab591adfc49d3fbc0d /Project-Unite/Controllers/GroupsController.cs | |
| parent | 2fdd32182c6cac6bc4d08ffca52cc64ba3d5fba6 (diff) | |
| download | project-unite-8e6196fd1d6b072ae14451a2119062e3401d1523.tar.gz project-unite-8e6196fd1d6b072ae14451a2119062e3401d1523.tar.bz2 project-unite-8e6196fd1d6b072ae14451a2119062e3401d1523.zip | |
JoinGroup action
Diffstat (limited to 'Project-Unite/Controllers/GroupsController.cs')
| -rw-r--r-- | Project-Unite/Controllers/GroupsController.cs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/GroupsController.cs b/Project-Unite/Controllers/GroupsController.cs index e3f0907..5213349 100644 --- a/Project-Unite/Controllers/GroupsController.cs +++ b/Project-Unite/Controllers/GroupsController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; +using Microsoft.AspNet.Identity; using Project_Unite.Models; namespace Project_Unite.Controllers @@ -17,6 +18,20 @@ namespace Project_Unite.Controllers } [Authorize] + public ActionResult JoinGroup(string id) + { + var db = new ApplicationDbContext(); + var user = db.Users.FirstOrDefault(x => x.Id == User.Identity.GetUserId()); + var group = db.Groups.FirstOrDefault(x => x.Id == id); + if (group == null) + return new HttpStatusCodeResult(404); + user.GroupId = id; + db.SaveChanges(); + return RedirectToAction("ViewGroup", "Groups", new { id = id }); + } + + + [Authorize] public ActionResult ViewGroup(string id) { var db = new ApplicationDbContext(); |
