public ListModelsQuery() { ListModelsQueryParamArg = new ListModelsQueryParamArg(); }
public QueryResult ListModels(ListModelsQueryParamArg listModelsQueryParamArg, QueryParamArg queryParamArg) { var birthDateFromAge = DateTime.Now.AddYears(-listModelsQueryParamArg.AgeFrom); var birthDateThruAge = DateTime.Now.AddYears(-(listModelsQueryParamArg.ThruAge + 1)); var result = ModelManagementContext() .Users.Where( t => t.IsUserActivated == "Y" && t.StatusId == Utility.StatusEnabled && t.UserRoleId_UserRoles.Any(l => l.RoleTypeId == Utility.RoleTypeModel) && (string.IsNullOrEmpty(listModelsQueryParamArg.Sex) || t.PersonId_PersonalInformation.Sex == listModelsQueryParamArg.Sex) && (listModelsQueryParamArg.CategoryTypeIds.Count == 0 || t.PersonId_PersonalInformation.Categories_PersonId.Any( c => listModelsQueryParamArg.CategoryTypeIds.Contains(c.CategoryTypeId)) ) && (listModelsQueryParamArg.HeightFrom == null || t.PersonId_PersonalInformation.PersonId_PhysicalInformation.Height >= listModelsQueryParamArg.HeightFrom) && (listModelsQueryParamArg.HeightThru == null || t.PersonId_PersonalInformation.PersonId_PhysicalInformation.Height <= listModelsQueryParamArg.HeightThru) && (string.IsNullOrEmpty(listModelsQueryParamArg.CategoryTypeId) || t.PersonId_PersonalInformation.Categories_PersonId .Any(c => c.CategoryTypeId == listModelsQueryParamArg.CategoryTypeId) ) && (listModelsQueryParamArg.AgeFrom == 0 || (t.PersonId_PersonalInformation.DateOfBirth.Value.Year <= birthDateFromAge.Year && (birthDateFromAge.Year - t.PersonId_PersonalInformation.DateOfBirth.Value.Year > 0 || t.PersonId_PersonalInformation.DateOfBirth.Value.Month <= birthDateFromAge.Month) )) && (listModelsQueryParamArg.ThruAge == 0 || (t.PersonId_PersonalInformation.DateOfBirth.Value.Year >= birthDateThruAge.Year && (t.PersonId_PersonalInformation.DateOfBirth.Value.Year - birthDateThruAge.Year > 0 || t.PersonId_PersonalInformation.DateOfBirth.Value.Month > birthDateThruAge.Month) )) && (string.IsNullOrEmpty(listModelsQueryParamArg.Complexion) || t.PersonId_PersonalInformation.PersonId_PhysicalInformation.Complexion == listModelsQueryParamArg.Complexion) && (string.IsNullOrEmpty(listModelsQueryParamArg.CountryGeoId) || t.PersonId_PersonalInformation.CountryGeoId == listModelsQueryParamArg.CountryGeoId) && (string.IsNullOrEmpty(listModelsQueryParamArg.CityGeoId) || t.PersonId_PersonalInformation.CityGeoId == listModelsQueryParamArg.CityGeoId) && (listModelsQueryParamArg.BmiFrom == null || t.PersonId_PersonalInformation.PersonId_PhysicalInformation.BmI >= listModelsQueryParamArg.BmiFrom) && (listModelsQueryParamArg.BmiThru == null || t.PersonId_PersonalInformation.PersonId_PhysicalInformation.BmI <= listModelsQueryParamArg.BmiThru) && (listModelsQueryParamArg.WeightFrom == null || t.PersonId_PersonalInformation.PersonId_PhysicalInformation.Weight >= listModelsQueryParamArg.WeightFrom) && (listModelsQueryParamArg.WeightThru == null || t.PersonId_PersonalInformation.PersonId_PhysicalInformation.Weight <= listModelsQueryParamArg.WeightThru) && (listModelsQueryParamArg.SelectedCities.Count == 0 || listModelsQueryParamArg.SelectedCities.Contains(t.PersonId_PersonalInformation.CityGeoId)) && (string.IsNullOrEmpty(listModelsQueryParamArg.ExperienceId) || t.PersonId_PersonalInformation.ExperienceEnumId == listModelsQueryParamArg.ExperienceId) ); return(result.QueryResultList <ModelListModel>(queryParamArg)); }