/// <inheritdoc/> public async Task <WeightTransaction> AddAsync(WeightTransaction item, CancellationToken cancellationToken) { _logger.LogInformation("Adding a new weight transaction for animal ({@AnimalId})", item.AnimalId); ValidateAddAsyncParameters(item); var transaction = new WeightTransactionModel { AnimalId = item.AnimalId, TransactionDate = item.TransactionDate, Weight = item.Weight }; var changes = _context.WeightTransactions.Add(transaction); await _context.SaveChangesAsync(cancellationToken).ConfigureAwait(false); return(changes.Entity.MapToWeightTransaction()); }
/// <summary> /// Maps a <see cref="WeightTransactionModel"/> to a <see cref="WeightTransaction"/>. /// </summary> /// <param name="entity">The EF model.</param> /// <returns>The domain model.</returns> public static WeightTransaction MapToWeightTransaction(this WeightTransactionModel entity) =>