public HttpResponseMessage GetAllError(HttpRequestMessage request) { try { var model = _errorService.GetAll(); return(request.CreateResponse(HttpStatusCode.OK, model)); } catch (Exception ex) { return(request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public ActionResult <IEnumerable <ErrorModel> > GetAll() { var errors = _errorService.GetAll(); if (errors == null) { return(NotFound()); } var errorsModel = _mapper.Map <IEnumerable <ErrorModel> >(errors); return(Ok(errorsModel)); }
public HttpResponseMessage GetAll(HttpRequestMessage request, int page, int pageSize) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; var model = _errorService.GetAll(); model = model.OrderByDescending(x => x.CreateDate).Skip(pageSize * (page - 1)).Take(pageSize); var modelVm = Mapper.Map <IEnumerable <Error>, IEnumerable <ErrorViewModel> >(model); PaginationSet <ErrorViewModel> pagedSet = new PaginationSet <ErrorViewModel> { PageIndex = page, PageSize = pageSize, TotalRows = modelVm.Count(), Items = modelVm }; response = request.CreateResponse(HttpStatusCode.OK, pagedSet); return response; })); }