/// <summary> /// Find a Job by specifying values for the properties available in the request. /// Date values: Start date will go from date forward, end date will be from end date back, and if both has values, /// it will be used as from (between) start to end /// </summary> /// <param name="request">The request used for building the find parameters</param> /// <returns>If LoadLazy was true, then a list of JarsJobBase items, otherwise a list of fully loaded JarsJobs</returns> public virtual JarsJobsResponse Any(FindJarsJobs request) { //return ExecuteFaultHandledMethod(() => //{ JarsJobsResponse response = new JarsJobsResponse(); if (request != null) { var query = BuildQuery(request); var _repository = _DataRepositoryFactory.GetDataRepository <IJarsJobRepository>(); response.Jobs = _repository.Where(query, request.FetchEagerly).ConvertAllTo <JarsJobDto>().ToList(); } return(response); ////}); }
/// <summary> /// A helper method used for building the query, depending on if the LoadLazy option was set. /// </summary> /// <typeparam name="T">A query over object required by the QueryOver Method on the repository</typeparam> /// <param name="request">The same request passed into the service</param> /// <returns></returns> private Expression <Func <JarsJob, bool> > BuildQuery(FindJarsJobs request) { Expression <Func <JarsJob, bool> > query = LinqExpressionBuilder.True <JarsJob>(); //Id if (request.Id != 0) { query = LinqExpressionBuilder.True <JarsJob>().And(j => j.Id == request.Id); } //ExtRefID if (request.ExtRefID != "0") { query = query.And(j => j.ExtRefId == request.ExtRefID); } //ResourceID if (request.ResourceId != 0) { query = query.And(j => j.ResourceId == request.ResourceId); } //Location if (request.Location != null) { query = query.And(j => j.Location == request.Location); } //CompletionDate if (request.ProgressStatus != null) { query = query.And(j => j.ProgressStatus == request.ProgressStatus); } //StartDateTime if (request.StartDate != DateTime.MinValue) { query = query.And(j => j.StartDate >= request.StartDate); } //EndDateTime if (request.EndDateTime != DateTime.MinValue) { query = query.And(j => j.EndDate <= request.EndDateTime); } return(query); }