public ActionResult WriteMessageAjax(MessageViewModel msg, string itemAttachments) { if (ModelState.IsValid && msg.FromId == WebSecurity.CurrentUserId) { try { var jsonSerializer = new JavaScriptSerializer(); var attachments = jsonSerializer.Deserialize<List<Attachment>>(itemAttachments); msg.Attachment = attachments; msg.SaveMessage(); return Json(new { code = 200, resultMessage = "Сообщение отправлено" }); } catch { return Json(new { code = 500, resultMessage = "При сохранении сообщения произошла ошибка" }); } } msg.Attachment = new List<Attachment>(); return PartialView("Common/_MessageForm", msg); }
public ActionResult WriteMessage(MessageViewModel msg, string itemAttachments) { var jsonSerializer = new JavaScriptSerializer(); var attachments = jsonSerializer.Deserialize<List<Attachment>>(itemAttachments); msg.Attachment = attachments; if (ModelState.IsValid && msg.FromId == WebSecurity.CurrentUserId) { msg.SaveMessage(); } return RedirectToAction("Index"); }