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.cs15
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();