Exemple #1
0
        public GetGeneralResponse <IEnumerable <AgencyView> > GetAgencies(bool?Discontinued, int pageSize, int pageNumber, IList <Sort> sort, IList <FilterData> filter)
        {
            GetGeneralResponse <IEnumerable <AgencyView> > response = new GetGeneralResponse <IEnumerable <AgencyView> >();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;
                Response <Agency> agencies = new Response <Agency>();
                //IList<Sort> sortOrders = new List<Sort>();
                //sortOrders.Add(new Sort("SortOrder"));
                if (filter != null)
                {
                    string query = FilterUtilityService.GenerateFilterHQLQuery(filter, "Agency", sort);
                    agencies = _agencyRepository.FindAll(query, index, count);
                }
                else
                {
                    agencies = _agencyRepository.FindAllWithSort(index, count, sort);
                }
                if (Discontinued == false)
                {
                    response.data = agencies.data.ConvertToAgencyViews().Where(x => x.Discontinued == false);
                }
                else
                {
                    response.data = agencies.data.ConvertToAgencyViews();
                }

                response.totalCount = agencies.totalCount;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }

            return(response);
        }