Esempio n. 1
0
        /// <summary>
        /// Get All Tariff Types based on search crateria
        /// </summary>
        public TariffTypeResponse GettariffTypes(TariffTypeSearchRequest tariffTypeRequest)
        {
            int fromRow = (tariffTypeRequest.PageNo - 1) * tariffTypeRequest.PageSize;
            int toRow   = tariffTypeRequest.PageSize;
            Expression <Func <TariffType, bool> > query =
                s => ((string.IsNullOrEmpty(tariffTypeRequest.SearchString) || s.TariffTypeCode.Contains(tariffTypeRequest.SearchString) || s.TariffTypeName.Contains(tariffTypeRequest.SearchString)) &&
                      (!(tariffTypeRequest.OperationId > 0) || s.OperationId == tariffTypeRequest.OperationId) &&
                      (!(tariffTypeRequest.MeasurementUnitId > 0) || s.MeasurementUnitId == tariffTypeRequest.MeasurementUnitId) &&
                      (string.IsNullOrEmpty(tariffTypeRequest.TariffTypeCode) || s.TariffTypeCode.Contains(tariffTypeRequest.TariffTypeCode))) &&
                (s.ChildTariffTypeId == 0 || s.ChildTariffTypeId == null);

            IEnumerable <TariffType> tariffTypes = tariffTypeRequest.IsAsc ? DbSet.Where(query)
                                                   .OrderBy(tariffTypeClause[tariffTypeRequest.TariffTypeByOrder]).Skip(fromRow).Take(toRow).ToList()
                                            : DbSet.Where(query)
                                                   .OrderByDescending(tariffTypeClause[tariffTypeRequest.TariffTypeByOrder]).Skip(fromRow).Take(toRow).ToList();


            return(new TariffTypeResponse {
                TariffTypes = tariffTypes, TotalCount = DbSet.Count(query)
            });
        }
Esempio n. 2
0
 // GET api/<controller>
 public TariffTypeSearchResponse Get([FromUri] TariffTypeSearchRequest request)
 {
     return(tariffTypeService.LoadtariffTypes((request)).CreateFrom());
 }
Esempio n. 3
0
 /// <summary>
 /// Load tariff type, based on search filters
 /// </summary>
 /// <param name="tariffTypeRequest"></param>
 /// <returns></returns>
 public TariffTypeResponse LoadtariffTypes(TariffTypeSearchRequest tariffTypeRequest)
 {
     return(tariffTypeRepository.GettariffTypes(tariffTypeRequest));
 }