Beispiel #1
0
        public QueueToUpdateDto ComposeQueueForUpdate(NewQueueDto queueDto, int id)
        {
            var queueForUpdate = _mapper.Map <QueueToUpdateDto>(queueDto);

            queueForUpdate.Id = id;
            return(queueForUpdate);
        }
        public async Task <ActionResult> ProcessQueueAdditionAsync(NewQueueDto newQueueDto)
        {
            Guard.Argument(() => newQueueDto).NotNull();

            var gameBM = await _queueOrchestrator.CreateQueueAsync(newQueueDto);

            return(new CreatedAtRouteResult(new { Id = gameBM.Id }, gameBM));
        }
        public async Task <ActionResult> ProcessQueueUpdateAsync(NewQueueDto newQueueDto, int id)
        {
            Guard.Argument(() => newQueueDto).NotNull();

            var queueDto = _queueComposer.ComposeQueueForUpdate(newQueueDto, id);
            await _queueOrchestrator.UpdateQueueAsync(queueDto);

            return(new NoContentResult());
        }
        public async Task <QueueBm> CreateQueueAsync(NewQueueDto queueDto)
        {
            Guard.Argument(() => queueDto).NotNull();
            var queueWithSameNameExists = await _storage.Queues.ExistsAsync(queueDto.Name);

            var queueBm = CheckBusinessRulesAndCreateQueue(queueDto);

            return(await _queueService.CreateQueueAsync(queueBm));
        }
        private QueueBm CheckBusinessRulesAndCreateQueue(NewQueueDto queueDto)
        {
            Guard.Argument(() => queueDto.Name).NotNull();
            var datesAreCorrect = queueDto.StartTime < queueDto.EndTime;

            Guard.Argument(() => datesAreCorrect).True();
            Guard.Argument(() => queueDto.TimeSlotDuration).Positive();
            Guard.Argument(() => queueDto.TimeSlotNumber).Positive();

            var queue = queueDto as QueueToUpdateDto;

            return(_mapper.Map <QueueBm>(queue ?? queueDto));
        }
Beispiel #6
0
 public async Task <ActionResult> Put(int?id, [FromBody] NewQueueDto newQueueDto)
 {
     return(_queueProcessService.ShouldCreateQueue(id)
         ? await _queueProcessService.ProcessQueueAdditionAsync(newQueueDto)
         : await _queueProcessService.ProcessQueueUpdateAsync(newQueueDto, (int)id));
 }
Beispiel #7
0
 public async Task <ActionResult> Post([FromBody] NewQueueDto queueDto)
 {
     return(await _queueProcessService.ProcessQueueAdditionAsync(queueDto));
 }