コード例 #1
0
        public async Task <Agreement> AddAgreementAsync(AgreementEntity agreementEntity)
        {
            await _databaseContext.Agreements.AddAsync(agreementEntity);

            await _databaseContext.SaveChangesAsync();

            return(agreementEntity.ToDomain());
        }
コード例 #2
0
 public static Agreement ToDomain(this AgreementEntity entity) =>
 new Agreement
 {
     Id           = entity.Id,
     Amount       = entity.Amount,
     BaseRateCode = entity.BaseRateCode,
     Duration     = entity.Duration,
     Margin       = entity.Margin
 };
コード例 #3
0
        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());
        }