public Models.AdditionalChargeSearchResponse Get([FromUri] AdditionalChargeSearchRequest request) { if (!ModelState.IsValid) { throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request"); } return(additionalChargeService.LoadAll(request).CreateFrom()); }
/// <summary> /// Get All Additional Charges based on search crateria /// </summary> public AdditionalChargeSearchResponse GetAdditionalCharges(AdditionalChargeSearchRequest request) { int fromRow = (request.PageNo - 1) * request.PageSize; int toRow = request.PageSize; Expression <Func <AdditionalChargeType, bool> > query = s => ((string.IsNullOrEmpty(request.SearchString) || s.AdditionalChargeTypeCode.Contains(request.SearchString) || s.AdditionalChargeTypeName.Contains(request.SearchString))); IEnumerable <AdditionalChargeType> additionalChargeTypes = request.IsAsc ? DbSet.Where(query) .OrderBy(additionalChargeClause[request.AdditionalChargeOrderBy]).Skip(fromRow).Take(toRow).ToList() : DbSet.Where(query) .OrderByDescending(additionalChargeClause[request.AdditionalChargeOrderBy]).Skip(fromRow).Take(toRow).ToList(); return(new AdditionalChargeSearchResponse { AdditionalChargeTypes = additionalChargeTypes, TotalCount = DbSet.Count(query) }); }
/// <summary> /// Load Additional Charge Based on search criteria /// </summary> /// <returns></returns> public AdditionalChargeSearchResponse LoadAll(AdditionalChargeSearchRequest request) { return(additionalChargeTypeRepository.GetAdditionalCharges(request)); }