public ActionResult Comment(int eventId, string content) { var service = new Service(); User user = service.GetUser(User.Identity.Name); if (String.IsNullOrEmpty(content)) { } else if (service.IsInvitedToEvent(user.UserID, eventId)) { Comment myComment = new Comment(); myComment.Content = content; myComment.Active = true; myComment.OwnerId = user.UserID; myComment.CreationTime = DateTime.Now; if (!service.CreateComment(eventId, ref myComment)) { TempData["Message"] = new Message("An Error occured when processing your event, please try again later", MessageType.ERROR); } } else { TempData["message"] = new Message("Either the event you are trying to access doesn't exist or you do not have sufficient access to it.", MessageType.INFORMATION); } if (Request.IsAjaxRequest()) { return Json(new { id = eventId, message = TempData["message"] as Message }, JsonRequestBehavior.AllowGet); } return RedirectToAction("Index"); }