Beispiel #1
0
        public ActionResult Create(ChatMessage chatMessage, int?roomid)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUsername");
            ModelState.Remove("When");

            if (ModelState.IsValid)
            {
                if (roomid == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                Room room = roomManager.Find(x => x.Id == roomid);

                if (room == null)
                {
                    return(new HttpNotFoundResult());
                }

                chatMessage.Room  = room;
                chatMessage.Owner = CurrentSession.User;

                if (chatMessageManager.Insert(chatMessage) > 0)
                {
                    return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
        }