public static Entity.Author ToEntity(this AuthorContract author) { return(new Entity.Author() { Id = author.Id, FirstName = author.FirstName, LastName = author.LastName, BirthDate = author.BirthDate, Country = author.Country, Articles = author.Articles != null?author.Articles.Select(x => x.ToEntity()).ToArray() : null }); }
public void Update(AuthorContract author) { Author.Entity.Author authorEntity = dbSet.FirstOrDefault(x => x.Id == author.Id); dbSet.Attach(authorEntity); authorEntity.FirstName = author.FirstName; authorEntity.LastName = author.LastName; authorEntity.BirthDate = author.BirthDate; authorEntity.Country = author.Country; dbContext.Entry(authorEntity).State = System.Data.Entity.EntityState.Modified; }
public void UpdateAuthor(AuthorContract author) { using (IUnitOfWork unitOfWork = unitOfWorkFactory.Create()) { if (author.Id == Guid.Empty) { author.Id = Guid.NewGuid(); unitOfWork.AuthorRepository.Create(author); } else { unitOfWork.AuthorRepository.Update(author); } unitOfWork.Save(); } }
public IHttpActionResult UpdateAuthor(AuthorContract author) { authorService.UpdateAuthor(author); return(Ok()); }
public IHttpActionResult GetAuthorById(Guid id) { AuthorContract author = authorService.GetAuthorById(id); return(Ok(author)); }
public void Create(AuthorContract author) { dbSet.Add(author.ToEntity()); }