public PriceTypeCommandHandlers(IUnitOfWork uow, IPriceTypeRepository repository,
                                 IPriceTypePolicy policy, IEventBus bus)
 {
     _uow        = uow ?? throw new ArgumentNullException(nameof(uow));
     _repository = repository ?? throw new ArgumentNullException(nameof(repository));
     _policy     = policy ?? throw new ArgumentNullException(nameof(policy));
     _bus        = bus ?? throw new ArgumentNullException(nameof(bus));
 }
Esempio n. 2
0
        public static Result <PriceType> New(Title title, IPriceTypePolicy policy)
        {
            if (title == null)
            {
                throw new ArgumentNullException(nameof(title));
            }
            if (policy == null)
            {
                throw new ArgumentNullException(nameof(policy));
            }

            var priceType = new PriceType(title);

            if (!policy.IsUnique(priceType))
            {
                return(Fail <PriceType>("PriceType Title Should Be Unique"));
            }

            priceType.RaiseDomainEvent(new PriceTypeCreated(priceType));

            return(Ok(priceType));
        }
 public NewPriceTypeHandler(IUnitOfWork uow, IPriceTypePolicy policy, IEventBus bus)
 {
     _uow    = uow ?? throw new ArgumentNullException(nameof(uow));
     _policy = policy ?? throw new ArgumentNullException(nameof(policy));
     _bus    = bus ?? throw new ArgumentNullException(nameof(bus));
 }
 public NewPriceTypeHandler(IDbContext dbContext, IPriceTypePolicy policy, IEventBus bus)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     _policy    = policy ?? throw new ArgumentNullException(nameof(policy));
     _bus       = bus ?? throw new ArgumentNullException(nameof(bus));
 }