/// <summary> /// Update note for NoteId /// </summary> /// <param name="note">The note.</param> /// <returns></returns> public Response <NoteDetailsViewModel> UpdateNoteDetails(NoteDetailsViewModel note) { string apiUrl = baseRoute + "UpdateNoteDetails"; var response = _communicationManager.Put <NoteDetailsModel, Response <NoteDetailsModel> >(note.ToModel(), apiUrl); return(response.ToViewModel()); }
public NoteDetailsPage(NoteDetailsViewModel viewModel) { InitializeComponent(); ViewModel = viewModel; BindingContext = this.ViewModel; Title = ViewModel.Title; }
public IActionResult DeleteNotePost(NoteDetailsViewModel noteDetailsViewModel) { try { _noteService.DeleteNote(noteDetailsViewModel.Id); return(RedirectToAction("Index")); } catch { return(View("ExceptionView")); } }
/// <summary> /// To the model. /// </summary> /// <param name="model">The model.</param> /// <returns></returns> public static NoteDetailsModel ToModel(this NoteDetailsViewModel model) { if (model == null) { return(null); } var entity = new NoteDetailsModel { NoteID = model.NoteID, Notes = model.Notes, ModifiedOn = model.ModifiedOn }; return(entity); }
/// <summary> /// To the ViewModel /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static NoteDetailsViewModel ToViewModel(this NoteDetailsModel entity) { if (entity == null) { return(null); } var model = new NoteDetailsViewModel { NoteID = entity.NoteID, Notes = entity.Notes, ModifiedOn = entity.ModifiedOn }; return(model); }
public void UpdateNoteDetails_Failure() { // Act var noteModel = new NoteDetailsViewModel { NoteID = -1, Notes = "Note Failure Update", ForceRollback = true }; var response = controller.UpdateNoteDetails(noteModel); // Assert Assert.IsNotNull(response, "Response can not be null"); Assert.IsTrue(response.RowAffected == 2, "Note details updated for invalid data."); //Update is logged operation, default rows affected is 2 }
public void UpdateNoteDetail_Success() { // Act var noteModel = new NoteDetailsViewModel { NoteID = 1, Notes = "Note Update", ForceRollback = true }; var response = controller.UpdateNoteDetails(noteModel); // Assert Assert.IsNotNull(response, "Response can not be null"); Assert.IsTrue(response.RowAffected > 2, "Note details could not be updated."); //Update is logged operation, default rows affected is 2 }
public IActionResult DeleteNote(int?id) { if (id == null) { return(View("BadRequest")); } try { NoteDetailsViewModel noteDetailsViewModel = _noteService.GetNoteById(id.Value); return(View(noteDetailsViewModel)); } catch { return(View("ExceptionView")); } }
public IActionResult Details(int id) { var noteModel = _noteRepository.GetNote(id); if (noteModel == null) { return(NotFound()); } NoteDetailsViewModel model = new NoteDetailsViewModel() { Content = noteModel.Content, Author = noteModel.Author, PhotoPath = noteModel.PhotoPath, }; return(View(model)); }
public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var note = await _context.Notes.Include(m => m.Items) .FirstOrDefaultAsync(m => m.Id == id && m.Owner == GetUserId()); if (note == null) { return(NotFound()); } var model = new NoteDetailsViewModel() { Id = note.Id, Title = note.Title, CreatedDate = note.CreatedDate, LastUpdatedDate = note.LastUpdatedDate }; if (note.Items != null) { model.Items = new List <NoteItemDetailsViewModel>(); foreach (var item in note.Items.OrderBy(m => m.Order)) { model.Items.Add(new NoteItemDetailsViewModel() { Id = item.Id, Content = item.Content, NoteId = item.NoteId, Type = item.Type, Order = item.Order }); } } ViewData["MapsKey"] = GetConfiguration("MapsKey"); return(View(model)); }
public NoteDetailsPage() { InitializeComponent(); BindingContext = ViewModel = new NoteDetailsViewModel(); ViewModel.SetData(new NotesModel()); }
public Response <NoteDetailsViewModel> UpdateNoteDetails(NoteDetailsViewModel note) { return(_noteRepository.UpdateNoteDetails(note)); }
public NoteDetails() { InitializeComponent(); DataContext = new NoteDetailsViewModel(); }