/// <summary> /// Adds an animal to the persisted store. /// </summary> /// <param name="item">The animal to be added.</param> /// <param name="cancellationToken">A token that can be used to signal operation cancellation.</param> /// <returns>The added animal.</returns> public virtual async Task <IAnimal> AddAsync(IAnimal item, CancellationToken cancellationToken) { Logger.LogInformation("Adding an animal..."); var entity = AnimalMapper.Map(item); var changes = await LivestockContext.AddAsync(entity, cancellationToken) .ConfigureAwait(false); await LivestockContext.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); return(AnimalMapper.Map(changes.Entity)); }