Beispiel #1
0
        public async Task <JsonResult> AddEditNote(DailyReportNoteViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Id == null)
                {
                    var note = DailyReportNote.Create(model.PersonId, model.ClassId, model.OrganizationId, model.Date, model.Note, _userId);
                    await _unitOfWork.DailyReportNotes.Insert(note);
                }
                else
                {
                    var note = await _unitOfWork.DailyReportNotes.GetOneAsync(x => x.IsActive && x.Id == model.Id);

                    note.Note = model.Note;
                    _unitOfWork.DailyReportNotes.Update(note);
                }
                var result = await _unitOfWork.SaveAsync();

                if (result.Succeeded)
                {
                    return(Json(new JsonMessage {
                        Color = "#ff6849", Message = "Note saved", Header = "Success", Icon = "success", AdditionalData = model
                    }));
                }
                return(Json(new JsonMessage {
                    Color = "#ff6849", Message = "Save Error", Header = "Error", Icon = "error", AdditionalData = model
                }));
            }
            else
            {
                return(Json(new JsonMessage {
                    Color = "#ff6849", Message = "Model Error", Header = "Error", Icon = "error", AdditionalData = model
                }));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> AddEditNote(Guid personId, Guid classId, Guid organizationId, DateTime?date = null)
        {
            if (date.HasValue == false)
            {
                date = DateTime.UtcNow;
            }

            var model = DailyReportNote.Init(personId, classId, organizationId, date.Value);

            return(View(model));
        }
Beispiel #3
0
 public static DailyReportNoteViewModel Create(DailyReportNote note)
 {
     return(new DailyReportNoteViewModel()
     {
         ClassId = note.ClassId,
         Id = note.Id,
         Date = note.Date,
         Note = note.Note,
         OrganizationId = note.OrganizationId,
         PersonId = note.PersonId
     });
 }