// Business public async Task <int> BusinessUpdateAsync(IBusiness business) { IDomainEvent <IBusiness> eventRaise; _dbContext.Entry((Business)business).State = EntityState.Modified; eventRaise = new BusinessUpdatedEvent(business); _recordsAffected = await _dbContext.SaveChangesAsync(); business.RaiseDomainEvent(eventRaise); return(_recordsAffected); }
public async Task <int> BusinessDeleteAsync(Guid key) { // Record in local storage IDomainEvent <IBusiness> eventRaise; var business = await _dbContext.Business.FindAsync(key); if (business.BusinessKey != Guid.Empty) { _dbContext.Entry((Business)business).State = EntityState.Deleted; eventRaise = new BusinessUpdatedEvent(business); _recordsAffected = await _dbContext.SaveChangesAsync(); business.RaiseDomainEvent(eventRaise); } return(_recordsAffected); }
public async Task <int> BusinessSaveAsync(IBusiness business) { // Record in local storage IDomainEvent <IBusiness> eventRaise; if (business.BusinessKey != Guid.Empty) { _dbContext.Entry((Business)business).State = EntityState.Modified; eventRaise = new BusinessUpdatedEvent(business); } else { _dbContext.Business.Add((Business)business); eventRaise = new BusinessCreatedEvent(business); } _recordsAffected = await _dbContext.SaveChangesAsync(); business.RaiseDomainEvent(eventRaise); return(_recordsAffected); }