void PurchaseApplicationRepository.Create(Domain.PurchaseApplication purchaseApplication) { using var dbContext = new PurchaseApplicationDbContext(); var dbEntity = BuildDbPurchaseApplication(purchaseApplication); dbContext.PurchaseApplications.Add(dbEntity); dbContext.SaveChanges(); }
public void Update(Domain.PurchaseApplication purchaseApplication) { using var dbContext = new PurchaseApplicationDbContext(); var purchaseApplicationPersistenceState = purchaseApplication.PersistenceState; var id = purchaseApplication.Id.State.Value; var dbEntity = dbContext.PurchaseApplications.FirstOrDefault(x => x.Id == id); if (dbEntity == null) { return; } dbEntity.RejectionDateTime = purchaseApplicationPersistenceState.Rejection.Map(x => x.DateTime).ToNullable(); dbEntity.RejectionReason = purchaseApplicationPersistenceState.Rejection.Map(x => x.Reason.Value).IfNoneUnsafe(() => null); dbContext.SaveChanges(); }