public JsonResult MessageTo(int toId, int fromId, string body, int? repliesTo) { try { var model = new MessageEditModel(); if (repliesTo.HasValue && repliesTo.Value != 0) model = _viewRepository.GetModelForReplyingTo(repliesTo.Value); else { model.ToUserId = toId; model.Subject = "New Message!"; } model.FromUserId = fromId; model.Body = body; model.Date = DateTime.Now; _viewRepository.Insert(model); return Json(new { success = true }, JsonRequestBehavior.AllowGet); } catch (Exception) { return Json(new {success = false }, JsonRequestBehavior.AllowGet); } }
public ActionResult Compose(MessageEditModel model) { if (ModelState.IsValid) { model.FromUserId = CurrentUser.OwnerId; _viewRepository.Insert(model); return RedirectToAction("Inbox"); } return View(model); }