コード例 #1
0
        public async Task <ActionResult> GetTimes([FromQuery] PaginateParameters paginateParameters)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var times = await _service.GetTimes(paginateParameters);

                var timesVideModel = _mapper.Map <List <TimeEntity>, List <TimeViewModel> >(times);
                var result         = new TimesPaginateViewModel();
                var qtdPagina      = await _service.Count();

                qtdPagina = qtdPagina / paginateParameters.TamanhoPagina + 1;

                result.Times         = timesVideModel;
                result.TamanhoPagina = paginateParameters.TamanhoPagina;
                result.QtdPagina     = qtdPagina;
                result.Pagina        = paginateParameters.Pagina;

                return(Ok(result));
            }
            catch (ArgumentException e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message));
            }
        }