/// <summary> /// Find a StandardAppointmentException 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 JarsStandardAppointmentExceptionBase items, otherwise a list of fully loaded JarsStandardAppointmentExceptions</returns> public virtual StandardAppointmentExceptionsResponse Any(FindStandardAppointmentExceptions request) { return(ExecuteFaultHandledMethod(() => { StandardAppointmentExceptionsResponse response = new StandardAppointmentExceptionsResponse(); if (request != null) { var query = BuildQuery <StandardAppointmentException>(request); //var _repository = _DataRepositoryFactory.GetDataRepository<IStandardAppointmentExceptionRepository>(); var _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <StandardAppointmentException, IDataContextNhJars> >(); response.AppointmentExceptions = _repository.Where(query).ToList().ConvertAll(x => x.ConvertTo <StandardAppointmentExceptionDto>()); } 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> /// <param name="hasWhere">a bool value indicating if there is a where string</param> /// <returns></returns> private Expression <Func <T, bool> > BuildQuery <T>(FindStandardAppointmentExceptions request) where T : StandardAppointmentException { Expression <Func <T, bool> > query = LinqExpressionBuilder.True <T>(); //Id if (request.Id != 0) { query = query.And(a => a.Id == request.Id); } //StartDateTime if (request.FromStartDate != DateTime.MinValue) { query = query.And(a => a.StartDate >= request.FromStartDate); } //EndDateTime if (request.ToEndDate != DateTime.MinValue) { query = query.And(a => a.EndDate <= request.ToEndDate); } return(query); }