public void MapToAuthorRepo(Models.Author author) { this.Author = new AuthorRepository() { Name = author.Name, Id = author.Id }; }
private void save(Models.Author Author, bool isUpdate = false) { if (!isUpdate) { this.context.Authors.Add(Author); } this.context.SaveChanges(); }
public void Update(long id, AuthorRepository authorRepository) { Models.Author oldAuthor = this.authorQueryRepository.Find(id); if (oldAuthor == null) { return; } oldAuthor.Name = authorRepository.Name; this.save(oldAuthor, true); }
public AuthorRepository FindById(long id = 0) { Models.Author author = this.Find(id); if (author == null) { return(new AuthorRepository()); } this.authorRepository.Id = author.Id; this.authorRepository.Name = author.Name; this.authorRepository.MapToListBook(author.Books); return(this.authorRepository); }
public void Delete(long id) { Models.Author author = this.context.Authors.Where(author => author.Id == id).FirstOrDefault(); this.context.Authors.Remove(author); this.context.SaveChanges(); }
public void Create(AuthorRepository authorRepository) { Models.Author newAuthor = new Models.Author(); newAuthor.Name = authorRepository.Name; this.save(newAuthor); }