Ejemplo n.º 1
0
        public async Task <IActionResult> GetUsersAsync([FromQuery] PaggedRequest paggedRequest)
        {
            var total = await _userDao.CountAsync(x => x.Id > 0);

            var users = await _userDao.GetManyAsync(paggedRequest.Page, paggedRequest.Size, x => x.Id > 0);

            var mapped = _mapper.Map <List <UserGetDto> >(users);

            return(Ok(new PagedResponse <List <UserGetDto> >(mapped, total, paggedRequest)));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetCustomerReservationsAsync(int customerId, [FromQuery] PaggedRequest paggedRequest)
        {
            var total = await _reservationDao.CountAsync(x => x.Customer.Id == customerId);

            if (total == 0)
            {
                return(NotFound(new ErrorResponse("Klient nie posiada rezerwacji.")));
            }

            var reservations = await _reservationDao.GetManyAsync(paggedRequest.Page, paggedRequest.Size, x => x.Customer.Id == customerId);

            var mapped = _mapper.Map <List <ReservationGetDto> >(reservations);

            return(Ok(new PagedResponse <List <ReservationGetDto> >(mapped, total, paggedRequest)));
        }