public async Task AddAsync(IPaymentRequest paymentRequest) { using (var context = _contextFactory.CreateDataContext()) { var entity = PartnerPaymentEntity.Create(paymentRequest); context.PartnersPayments.Add(entity); await context.SaveChangesAsync(); } }
public async Task UpdatePaymentAsync(PaymentModel paymentModel) { using (var context = _contextFactory.CreateDataContext()) { var entity = PartnerPaymentEntity.Create(paymentModel); entity.LastUpdatedTimestamp = DateTime.UtcNow; context.PartnersPayments.Update(entity); await context.SaveChangesAsync(); } }
public async Task SetStatusAsync(string paymentRequestId, PaymentRequestStatus status) { using (var context = _contextFactory.CreateDataContext()) { var entity = new PartnerPaymentEntity { PaymentRequestId = paymentRequestId }; context.PartnersPayments.Attach(entity); entity.Status = status; entity.LastUpdatedTimestamp = DateTime.UtcNow; try { await context.SaveChangesAsync(); } catch (DbUpdateException) { throw new InvalidOperationException("Entity was not found during status update"); } } }