Esempio n. 1
0
 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);
 }
Esempio n. 2
0
        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();
        }