public async Task <HttpResponseMessage> GetMostViewerNews(int userID, int currentIndex, int maxRows) { try { NewsDAL dal = new NewsDAL(); List <NewsInfo> data = await dal.GetMostViewerNews(userID, currentIndex, maxRows); if (data != null) { return(Request.CreateResponse <List <NewsInfo> >(HttpStatusCode.OK, data)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Constants.ErrorNotFound)); } } catch (DbEntityValidationException ex) { var controllerName = ControllerContext.RouteData.Values["controller"].ToString(); var actionName = ControllerContext.RouteData.Values["action"].ToString(); Logger log = new Logger(); log.ErrorLog(ex, controllerName, actionName); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Constants.ErrorSysError)); } }