public ActionResult DeleteConfirmed(int id) { InChatRoom inChatRoom = db.InChatRooms.Find(id); db.InChatRooms.Remove(inChatRoom); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,UserId,ChatRoomId")] InChatRoom inChatRoom) { if (ModelState.IsValid) { db.Entry(inChatRoom).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ChatRoomId = new SelectList(db.ChatRooms, "Id", "Id", inChatRoom.ChatRoomId); ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", inChatRoom.UserId); return(View(inChatRoom)); }
public ActionResult Create([Bind(Include = "Id,UserId,ChatRoomId")] InChatRoom inChatRoom) { if (ModelState.IsValid) { db.InChatRooms.Add(inChatRoom); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ChatRoomId = new SelectList(db.ChatRooms, "Id", "Id", inChatRoom.ChatRoomId); ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", inChatRoom.UserId); return(View(inChatRoom)); }
// GET: InChatRooms/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InChatRoom inChatRoom = db.InChatRooms.Find(id); if (inChatRoom == null) { return(HttpNotFound()); } return(View(inChatRoom)); }
// GET: InChatRooms/Delete/5 public ActionResult Delete(int?user, Guid?room) { InChatRoom inChatRoom = db.InChatRooms.SingleOrDefault(c => ((c.UserId == user) && (c.ChatRoomId == room))); if (inChatRoom != null) { db.InChatRooms.Remove(inChatRoom); } db.SaveChanges(); return(RedirectToAction("Index", "ChatRooms")); }
// GET: InChatRooms/Create public ActionResult Create(Guid id) { ViewBag.ChatRoomId = new SelectList(db.ChatRooms, "Id", "Id"); ViewBag.UserId = new SelectList(db.Users, "Id", "Username"); InChatRoom newInChat = new InChatRoom(); newInChat.ChatRoomId = id; newInChat.UserId = (int)Session["userId"]; db.InChatRooms.Add(newInChat); db.SaveChanges(); return(RedirectToAction("Index", "ChatRooms")); }
// GET: InChatRooms/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InChatRoom inChatRoom = db.InChatRooms.Find(id); if (inChatRoom == null) { return(HttpNotFound()); } ViewBag.ChatRoomId = new SelectList(db.ChatRooms, "Id", "Id", inChatRoom.ChatRoomId); ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", inChatRoom.UserId); return(View(inChatRoom)); }
public ActionResult Create([Bind(Include = "Id,CreatorID,TimeCreated")] ChatRoom chatRoom) { User myUser = db.Users.SingleOrDefault(u => u.Id == chatRoom.CreatorID); if (myUser.TokenAmount >= priceOfNewChatRoom) { if (ModelState.IsValid) { myUser.TokenAmount -= priceOfNewChatRoom; chatRoom.Id = Guid.NewGuid(); chatRoom.TimeCreated = DateTime.UtcNow; //--- Adding user in chatRoom in Db --- InChatRoom inChatRoom = new InChatRoom(); inChatRoom.ChatRoomId = chatRoom.Id; inChatRoom.UserId = chatRoom.CreatorID; db.ChatRooms.Add(chatRoom); db.InChatRooms.Add(inChatRoom); db.Entry(myUser).State = EntityState.Modified; db.SaveChanges(); Session["chatRoomId"] = chatRoom.Id; return(RedirectToAction("Index")); } } else { ViewBag.message = "Not enough tokens"; } return(View(chatRoom)); }