public ActionResult Private(FormCollection collection) { JodADataContext db = new JodADataContext(); aspnet_User newMember = (from p in db.aspnet_Users where p.UserId.ToString() == collection["SelectedValue"] select p).First(); ChatRoom room = (from p in db.ChatRooms where p.RoomID.ToString() == collection["item.RoomID"] select p).First(); aspnet_User user = (from p in db.aspnet_Users where p.UserName == User.Identity.Name select p).First(); if (room.UserID != user.UserId) { Session["jomarmessage"] = "You can't add users to a room you don't own."; return Redirect(Url.Action("Private", "Rooms")); } List<Guid> mmm = new List<Guid>(); foreach (var s in room.UserRooms) mmm.Add(s.UserID); if (!mmm.Contains(newMember.UserId)) { UserRoom ur = new UserRoom(); ur.RoomID = room.RoomID; ur.UserID = newMember.UserId; db.UserRooms.InsertOnSubmit(ur); db.SubmitChanges(); } Models.MyRoom model = new Models.MyRoom(user, db); return View(model); }
public ActionResult Private() { JodADataContext db = new JodADataContext(); aspnet_User user = (from p in db.aspnet_Users where p.UserName == User.Identity.Name select p).First(); Models.MyRoom model = new Models.MyRoom(user, db); return View(model); }