public bool UpdateByNotePatch(NotePatch notePatch) { Title = notePatch.Title; Description = notePatch.Description; NoteStatus = notePatch.NoteStatus; return(true); }
public void CreateModelTest() { var userModel = Registry.User.CreateModel( "*****@*****.**", "FirstName", "LastName", UserStatus.Confirmed ).Result; Assert.NotNull(userModel); var patch = new NotePatch( "Perfect note", "Hello world", NoteStatus.Disabled ); var model = Registry.Note.CreateModel( userModel.Id, patch.Title, patch.Description, patch.NoteStatus ).Result; Assert.NotNull(model); Assert.Equal(userModel.Id, model.AuthorId); Assert.Equal(patch.Title, model.Title); Assert.Equal(patch.Description, model.Description); Assert.Equal(patch.NoteStatus, model.NoteStatus); }
public Task <NoteModel> CreateModel( int authorId, NotePatch notePatch ) { return(CreateModel( authorId, notePatch.Title, notePatch.Description, notePatch.NoteStatus )); }
public async Task <NoteModel> UpdatePatch(NoteModel model, NotePatch notePatch) { if (model.IsSame(notePatch)) { return(model); } model.UpdateByNotePatch(notePatch); var result = await UpdateModelAsync(model); if (result == 0) { throw new ErrorException(Error.Create("Note Model not updated", ErrorType.DbError)); } return(model); }
public static NoteModel CreateNoteModel( NoteRepository noteRepository, UserModel userModel, NotePatch notePatch = null ) { var uniqueName = new Guid().ToString("N"); if (notePatch == null) { notePatch = new NotePatch( "Title_" + uniqueName, "Desc_" + uniqueName, NoteStatus.Disabled ); } return(noteRepository.CreateModel(userModel.Id, notePatch).Result); }
public void UpdatePatchTest() { var userModel = Registry.User.CreateModel( "*****@*****.**", "FirstName", "LastName", UserStatus.Confirmed ).Result; var model = Fixtures.NoteFixture.CreateNoteModel(Registry.Note, userModel); var patch = new NotePatch( "It is not a perfect note :(", "Success or die", NoteStatus.Published ); var updatedModel = Registry.Note.UpdatePatch(model, patch).Result; Assert.NotNull(updatedModel); Assert.Equal(patch.Title, updatedModel.Title); Assert.Equal(patch.Description, updatedModel.Description); Assert.Equal(patch.NoteStatus, updatedModel.NoteStatus); }
//if this method return false, then we update model by UpdateByNotePatch method public bool IsSame(NotePatch notePatch) { return(notePatch.Title == Title && notePatch.Description == Description && notePatch.NoteStatus == NoteStatus); }