Beispiel #1
0
        /// <inheritdoc />
        public override int SaveChanges()
        {
            // Dispatch Domain Events collection.
            _mediator.DispatchDomainEvents(this);

            return(base.SaveChanges());
        }
        public PayLoad AddPayLoad(PayLoad payLoad)
        {
            int id = 0;

            DataModels.PayLoadDataModel payLoadEntity =
                _dataBase.GetPaylod(payLoad.ProvidedPayLoadId, payLoad.Origin);

            if (payLoadEntity != null)
            {
                id = payLoadEntity.Id;
                payLoadEntity.Data = payLoad.Data;
                _dataBase.UpdatePayLoad(payLoadEntity);
            }
            else
            {
                id = _dataBase.AddPayLoad(new DataModels.PayLoadDataModel()
                {
                    ProvidedPayLoadId = payLoad.ProvidedPayLoadId,
                    Origin            = payLoad.Origin,
                    Data = payLoad.Data
                });
            }

            _mediator.DispatchDomainEvents(payLoad);

            DataModels.PayLoadDataModel newlyEntity = _dataBase.GetPaylodById(id);

            if (newlyEntity == null)
            {
                return(null);
            }
            else
            {
                return(new PayLoad(newlyEntity.Id, newlyEntity.ProvidedPayLoadId, newlyEntity.Origin, newlyEntity.Data));
            }
        }
    public override async Task <int> SaveChangesAsync(CancellationToken cancellationToken = default)
    {
        await _mediator.DispatchDomainEvents(this);

        return(await base.SaveChangesAsync(cancellationToken));
    }