public Task <Unit> Handle(CreateSlotCommand request, CancellationToken cancellationToken)
        {
            if (_slotService.Count(i => i.OwnerId == request.UserId) > 10)
            {
                throw new RequestException("No more than 10 slots allowed.");
            }

            _slotService.Add(new MerchSlot
            {
                Name    = request.Name,
                OwnerId = request.UserId,
            });

            return(Unit.Task);
        }
        public Task <Unit> Handle(CreateMerchItemCommand request, CancellationToken cancellationToken)
        {
            if (_itemsService.Count(i => i.OwnerId == request.UserId) > 100)
            {
                throw new RequestException("No more than 100 items allowed.");
            }

            var item = new MerchItem
            {
                OwnerId    = request.UserId,
                ItemTypeId = _typeService.FirstOrDefault(type => type.Kind == request.MerchItem.Kind).Id,
                Name       = request.MerchItem.Name,
                ImageUrl   = request.MerchItem.ImageUrl
            };

            _itemsService.Add(item);

            return(Unit.Task);
        }
 public int Count()
 {
     return(_serviceBase.Count());
 }
Example #4
0
 public virtual int Count()
 {
     return(_service.Count());
 }
 public int Count(Expression <Func <TViewModel, bool> > where)
 {
     return(_service.Count(MapWhere(where)));
 }