public List <AdmissionsNewsManagerResponseDto> GetAdmissionNewsList(AdmissionNewsManagerConditionSearch conditionSearch) { // Nếu không tồn tại điều kiện tìm kiếm thì khởi tạo giá trị tìm kiếm ban đầu if (conditionSearch == null) { conditionSearch = new AdmissionNewsManagerConditionSearch(); } // Lấy các thông tin dùng để phân trang var paging = new Paging(context.AdmissionNews.Count(x => !x.DelFlag && (conditionSearch.KeySearch == null || (conditionSearch.KeySearch != null && (x.Title.Contains(conditionSearch.KeySearch))))) , conditionSearch.CurrentPage, conditionSearch.PageSize); // Tìm kiếm và lấy dữ liệu theo trang var listOfNews = context.AdmissionNews.Where(x => !x.DelFlag && (conditionSearch.KeySearch == null || (conditionSearch.KeySearch != null && (x.Title.Contains(conditionSearch.KeySearch))))) .OrderBy(x => x.Id) .Skip((paging.CurrentPage - 1) * paging.PageSize) .Take(paging.PageSize).Select(x => new AdmissionsNewsManagerResponseDto { Id = x.Id, Title = x.Title, ImageUrl = x.ImageUrl, Summary = x.Summary, Content = x.Content }).ToList(); return(listOfNews == null ? null : listOfNews); }
public IHttpActionResult GetAdmissionNewsList([FromBody] AdmissionNewsManagerConditionSearch conditionSearch) { try { return(Ok(_admissionNewsManagerService.GetAdmissionNewsList(conditionSearch))); } catch (System.Exception e) { return(InternalServerError(e)); } }