public async Task <Agreement> AddAgreementAsync(AgreementEntity agreementEntity) { await _databaseContext.Agreements.AddAsync(agreementEntity); await _databaseContext.SaveChangesAsync(); return(agreementEntity.ToDomain()); }
public static Agreement ToDomain(this AgreementEntity entity) => new Agreement { Id = entity.Id, Amount = entity.Amount, BaseRateCode = entity.BaseRateCode, Duration = entity.Duration, Margin = entity.Margin };
public async Task <Agreement> UpdateAgreementAsync(AgreementEntity agreementEntity) { var agreementId = agreementEntity.Id; var currentAgreement = await _databaseContext.Agreements.FindAsync(agreementId); if (currentAgreement == null) { throw new ArgumentNullException(nameof(agreementEntity), $"Agreement entity with Id: {agreementId} was not found"); } currentAgreement.Amount = agreementEntity.Amount; currentAgreement.BaseRateCode = agreementEntity.BaseRateCode; currentAgreement.CustomerId = agreementEntity.CustomerId; currentAgreement.Duration = currentAgreement.Duration; _databaseContext.Agreements.Update(currentAgreement); await _databaseContext.SaveChangesAsync(); return(currentAgreement.ToDomain()); }