Пример #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
                }));
            }
        }
Пример #2
0
        public async Task <IActionResult> EditNote(Guid id)
        {
            var note = await _unitOfWork.DailyReportNotes.GetOneAsync(x => x.IsActive && x.Id == id);

            return(View("AddEditNote", DailyReportNoteViewModel.Create(note)));
        }