public ActionResult DeclineFriend(int? id) { using (var db = new ObjectDatabase()) { var x = db.Friendships.Single(m => m.FriendshipId == id); if (x == null) return new HttpNotFoundResult(); db.Friendships.Remove(x); db.SaveChanges(); } return RedirectToAction("FriendList", "Admin"); }
public ActionResult AcceptFriend(int? id) { using (var db = new ObjectDatabase()) { var x = db.Friendships.SingleOrDefault(m => m.FriendshipId == id); if (x == null) return new HttpNotFoundResult(); x.Accepted = true; db.SaveChanges(); } return RedirectToAction("FriendList", "Admin"); }
public JsonResult ChatAdd(ChatObject aaa) { var objs = new List<ChatObject>(); aaa.Timestamp = DateTime.Now; using (var db = new ObjectDatabase()) { db.ChatLog.Add(aaa); db.SaveChanges(); var x = db.ChatLog.Where(m => m.BoardId == aaa.BoardId); objs.AddRange(x.ToArray()); } return Json(objs); }
public JsonResult Delete(GraphicObject aaa) { string uid = User.Identity.GetUserId(); var objs = new List<GraphicObject>(); using (var db = new ObjectDatabase()) { var z = db.Permissions.SingleOrDefault(m => (m.BoardId == aaa.BoardId && m.UserId == uid && m.DeleteObject == true)); if (z != null) { var obj = db.GraphicObjects.SingleOrDefault(m => m.GraphicObjectId == aaa.GraphicObjectId); if (obj != null) { db.GraphicObjects.Remove(obj); db.SaveChanges(); } } var x = db.GraphicObjects.Where(m => m.BoardId == aaa.BoardId); objs.AddRange(x.ToArray()); } return Json(objs); }
public ActionResult _PermissionPartial(Permission a) { //a.UserId = User.Identity.GetUserId(); using (var db = new ObjectDatabase()) { db.Permissions.Add(a); db.SaveChanges(); } ViewBag.Status = "success"; return RedirectToAction("PermissionList"); }
public ActionResult _FriendPartial(Friendship a) { a.UserId = User.Identity.GetUserId(); using (var db = new ObjectDatabase()) { db.Friendships.Add(a); db.SaveChanges(); } ViewBag.Status = "success"; return RedirectToAction("FriendList"); }
public ActionResult _BoardPartial(Board a) { a.UserId = User.Identity.GetUserId(); using (var db = new ObjectDatabase()) { db.Boards.Add(a); db.SaveChanges(); db.Permissions.Add(new Permission { UserId = a.UserId, BoardId = a.BoardId, AddObject = true, DeleteObject = true, EditObject = true }); db.SaveChanges(); } ViewBag.Status = "success"; return RedirectToAction("BoardList"); }
public JsonResult Update(GraphicObject aaa) { string uid = User.Identity.GetUserId(); var objs = new List<GraphicObject>(); using (var db = new ObjectDatabase()) { var z = db.Permissions.SingleOrDefault(m => (m.BoardId == aaa.BoardId && m.UserId == uid && m.EditObject == true)); if (z != null) { var obj = db.GraphicObjects.SingleOrDefault(m => m.GraphicObjectId == aaa.GraphicObjectId); if (obj != null) { obj.x = aaa.x; obj.y = aaa.y; obj.fill = aaa.fill; obj.stroke = aaa.stroke; obj.stroke_width = aaa.stroke_width; obj.width = aaa.width; obj.height = aaa.height; db.SaveChanges(); } } var x = db.GraphicObjects.Where(m => m.BoardId == aaa.BoardId); objs.AddRange(x.ToArray()); } return Json(objs); }