Пример #1
0
 public HomeViewModel Initialize()
 {
     var model = new HomeViewModel
     {
         Projects = new List<Project>(),
         Message = new Message()
     };
     model.Projects = _projects.Load(0, 3);
     SetNews(model.Projects);
     return model;
 }
Пример #2
0
 public ActionResult Send(HomeViewModel model)
 {
     SetData(model);
     if (!ModelState.IsValid) return RedirectToAction("Index");
     _homeService.SendMessage(model);
     try
     {
         ModelState.Clear();
     }
     catch (NotSupportedException notSupportedException)
     {
         return Json("Сообщение отправлено\n" + notSupportedException.Message);
     }
     return Json("Сообщение отправлено");
 }
Пример #3
0
 private void SetData(HomeViewModel model)
 {
     model.Message.AuthorId = User.Identity.GetUserId();
     model.Message.Date = DateTime.Now;
 }
Пример #4
0
 public void SendMessage(HomeViewModel model)
 {
     _message.Add(model.Message);
 }