public bool UpdateTreatmentNote(TreatmentNoteEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.TreatmentNotes.Single(e => e.TreatmentNoteId == model.TreatmentNoteId && e.AuthorId == _userId);
                entity.StartTime = model.StartTime;
                entity.EndTime   = model.EndTime;
                entity.Content   = model.Content;
                entity.Modified  = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            var service = CreateTreatmentNoteService();
            var detail  = service.GetNoteById(id);
            var model   = new TreatmentNoteEdit
            {
                TreatmentNoteId = detail.TreatmentNoteId,
                StartTime       = detail.StartTime,
                EndTime         = detail.EndTime,
                Content         = detail.Content
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id, TreatmentNoteEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.TreatmentNoteId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }
            var service = CreateTreatmentNoteService();

            if (service.UpdateTreatmentNote(model))
            {
                TempData["SaveResult"] = "Your note was updated.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your note could not be updated.");
            return(View(model));
        }