public ActionResult AddNewMark(int forWhom) { var authorUser = (UserViewModel) Session["CurrentUser"]; User toUser = repository.GetUsers().FirstOrDefault(x => x.Id == forWhom); var mark = new MarkEditModel { From = authorUser.FullName, To = toUser == null ? "Неизвестный пользователь" : toUser.FirstName, ToId = forWhom }; return View(mark); }
public void SaveMark(MarkEditModel model) { var authorUser = (UserViewModel) Session["CurrentUser"]; model.Date = DateTime.Today; model.FromId = authorUser.Id; repository.AddMarks(new List<Mark> { new Mark { DateTime = model.Date.Value, FromId = model.FromId.Value, ToId = model.ToId, Json = JsonConvert.SerializeObject(model.MarkDetails) } }); repository.Save(); }