示例#1
0
        public Task <Unit> Handle(DeleteUsagePeriodCommand request, CancellationToken cancellationToken)
        {
            var period = _periodService.CheckOwnership(request, request.Id);

            _periodService.Remove(period);

            return(Unit.Task);
        }
示例#2
0
        public Task <Unit> Handle(DeleteMerchItemCommand request, CancellationToken cancellationToken)
        {
            var item = _itemsService.CheckOwnership(request, request.Id);

            _itemsService.Remove(item);

            return(Unit.Task);
        }
示例#3
0
        public Task <Unit> Handle(UpdateMerchItemCommand request, CancellationToken cancellationToken)
        {
            var item = _itemsService.CheckOwnership(request, request.MerchItem.Id);

            item.Name       = request.MerchItem.Name;
            item.ImageUrl   = request.MerchItem.ImageUrl;
            item.ItemTypeId = _typeService.FirstOrDefault(type => type.Kind == request.MerchItem.Kind).Id;

            _itemsService.Update(item);

            return(Unit.Task);
        }
        public Task <Unit> Handle(CreateUsagePeriodCommand request, CancellationToken cancellationToken)
        {
            _itemService.CheckOwnership(request, request.MerchItemId);
            _slotService.CheckOwnership(request, request.SlotId);

            _periodService.Add(new MerchItemUsagePeriod
            {
                OwnerId = request.UserId,

                Start = request.Start,
                End   = request.End,

                MerchItemId = request.MerchItemId,
                MerchSlotId = request.SlotId,
            });

            return(Unit.Task);
        }
示例#5
0
        public Task <TimelineEntry> Handle(ModifyPeriodCommand request, CancellationToken cancellationToken)
        {
            var period = _periodService.CheckOwnership(request, request.Id,
                                                       periods => periods.Include(usagePeriod => usagePeriod.MerchItem));

            period.Start = request.Start;
            period.End   = request.End;

            _periodService.Update(period);

            return(Task.FromResult(new TimelineEntry
            {
                Id = period.Id,

                End = period.End,
                Start = period.Start,

                Name = period.MerchItem.Name,
                ImageUrl = period.MerchItem.ImageUrl
            }));
        }