Example #1
0
        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);
        }
Example #2
0
        public ActionResult WriteMessage(int? id, bool toadmin = false, string resubject = "")
        {
            var messageViewModel = new MessageViewModel(toadmin)
                {
                    FromId = WebSecurity.CurrentUserId,
                    Attachment = new List<Attachment>(),
                    Subject = string.IsNullOrEmpty(resubject) ? resubject : "Re:" + resubject,
                };

            if (id.HasValue)
            {
                messageViewModel.Recipients = new List<int>() { id.Value };
            }

            return PartialView("Common/_MessageForm", messageViewModel);
        }
Example #3
0
        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");
        }