Exemplo n.º 1
0
        // 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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }