Example #1
0
        public async Task <Response <List <BookingEntityViewModel> > > Handle(GetReservedTablesCommand request,
                                                                              CancellationToken cancellationToken)
        {
            var validationResult = await _getReservedTablesCommandValidator.ValidateAsync(request, cancellationToken);

            if (!validationResult.IsValid)
            {
                throw new Exception("Request is invalid");
            }

            var all = await _bookingEntityRepository.GetAllAsync();

            var count = request.Count + request.Offset * request.Count;

            var items          = all.Take(count).ToList();
            var itemsDto       = _mapper.MapList <BookingEntityDto, BookingEntity>(items);
            var itemsViewModel = _mapper.MapList <BookingEntityViewModel, BookingEntityDto>(itemsDto);

            return(new Response <List <BookingEntityViewModel> >
            {
                Item = itemsViewModel
            });
        }
 public async Task <IActionResult> GetReservedTables([FromBody] GetReservedTablesCommand getReservedTablesCommand)
 {
     return(await SendRequest(getReservedTablesCommand));
 }