private void OnFocusOutEvent(object o, FocusOutEventArgs args) { if (AcceptUnknownCities && (!Text.ToLower().Contains(CityName.ToLower()) || string.IsNullOrWhiteSpace(CityName)) ) { CityName = Text; UpdateFromFias(); FireCityChange(); } }
public SearchFilter ApplyFilter() { if (CityName == "" && FacultyName == "" && ProfessorName == "" && MinReview == 0 && MaxReview == Int16.MaxValue) { return(this); } if (CityName != "") { Cities = Cities.Where(city => city.Name.ToLower().Contains(CityName.ToLower())); Faculties = Cities.SelectMany(c => c.Universities).SelectMany(u => u.Faculties); Subjects = Subjects.Where(s => Faculties.Contains(s.Faculty)); var professors = Subjects.SelectMany(s => s.Professors).Select(s => s.Professor); Professors = Professors.Where(p => professors.Contains(p)); } if (FacultyName != "") { Faculties = Faculties.Where(faculty => faculty.Name.ToLower().Contains(FacultyName.ToLower())); Subjects = Subjects.Where(s => Faculties.Contains(s.Faculty)); var professors = Subjects.SelectMany(s => s.Professors).Select(s => s.Professor); Professors = Professors.Where(p => professors.Contains(p)); } if (ProfessorName != "") { Professors = Professors.Where(professor => professor.FullName.ToLower().Contains(ProfessorName.ToLower())); var subjects = Professors.SelectMany(p => p.Subjects).Select(p => p.Subject); Subjects = Subjects.Where(s => subjects.Contains(s)); } if (MinReview.HasValue) { Professors = Professors.Where(professor => professor.Reviews.Count >= MinReview); Subjects = Subjects.Where(subject => subject.Reviews.Count >= MinReview); } if (MaxReview.HasValue) { Professors = Professors.Where(professor => professor.Reviews.Count <= MaxReview); Subjects = Subjects.Where(subject => subject.Reviews.Count <= MaxReview); } return(this); }
private bool CheckData(DataTable dt) { int TotalCount = 0, SuccessCount = 0, FailCount = 0; string Message = string.Empty; try { for (int i = 0; i < dt.Rows.Count; i++) { TotalCount++; bool IsValid = true; int CountryId = 0, StateId = 0, CityId = 0; string Connecter = " in Record-" + TotalCount.ToString() + ".<br />"; #region Value Initialization CountryName = dt.Rows[i][CountryNameColumn].ToString().Trim(); StateName = dt.Rows[i][StateNameColumn].ToString().Trim(); CityName = dt.Rows[i][CityNameColumn].ToString().Trim(); AreaName = dt.Rows[i][AreaNameColumn].ToString().Trim(); #endregion #region Check Country Name if (IsValid) { if (CountryName.zIsNullOrEmpty()) { Message += CS.Arrow + "Country Name Is Empty" + Connecter; IsValid = false; } } if (IsValid) { var lstCountry = new Country() { CountryName = CountryName.ToLower(), eStatus = (int)eStatus.Active, }.SelectList <Country>(); if (lstCountry.Count == 0) { Message += CS.Arrow + "Country is Invalid" + Connecter; IsValid = false; } else { CountryId = lstCountry[0].CountryId.Value; } } #endregion #region Check State Name if (IsValid) { if (StateName.zIsNullOrEmpty()) { Message += CS.Arrow + "State Name Is Empty" + Connecter; IsValid = false; } } if (IsValid) { var lstState = new State() { StateName = StateName.ToLower(), CountryId = CountryId, eStatus = (int)eStatus.Active }.SelectList <State>(); if (lstState.Count == 0) { Message += CS.Arrow + "State is Invalid" + Connecter; IsValid = false; } else { StateId = lstState[0].StateId.Value; } } #endregion #region Check City Name if (IsValid) { if (CityName.zIsNullOrEmpty()) { Message += CS.Arrow + "City Name Is Empty" + Connecter; IsValid = false; } } if (IsValid) { var lstCity = new City() { CityName = CityName.ToLower(), StateId = StateId, eStatus = (int)eStatus.Active }.SelectList <City>(); if (lstCity.Count == 0) { Message += CS.Arrow + "City is Invalid" + Connecter; IsValid = false; } else { CityId = lstCity[0].StateId.Value; } } #endregion #region Check Area Name if (IsValid) { if (AreaName.zIsNullOrEmpty()) { Message += CS.Arrow + "Area Name Is Empty" + Connecter; IsValid = false; } } if (IsValid) { string RepeateColumn = string.Empty; if (CU.IsRepeateExcelRow(dt, i, AreaName, AreaNameColumn, CityName, CityNameColumn, StateName, StateNameColumn, ref RepeateColumn)) { Message += CS.Arrow + "Area " + AreaName + " is Repeating in Record-" + RepeateColumn; IsValid = false; } } if (IsValid) { DataTable dtAreaName = new Query() { CountryId = CountryId, StateId = StateId, CityId = CityId, AreaName = AreaName, eStatusNot = (int)eStatus.Delete }.Select(eSP.qry_Area); if (dtAreaName.Rows.Count > 0 && !chkReplace.Checked) { string Status = dtAreaName.Rows[0][CS.eStatus].zToInt().Value == (int)eStatus.Deactive ? "(Deactive)" : string.Empty; Message += CS.Arrow + AreaName + " Area is already exist" + Status + "." + Connecter; IsValid = false; } } #endregion #region Check Pincode if (!Pincode.zIsNullOrEmpty()) { if (IsValid) { string RepeateColumn = string.Empty; if (CU.IsRepeateExcelRow(dt, i, Pincode, PincodeColumn, string.Empty, null, string.Empty, null, ref RepeateColumn)) { Message += CS.Arrow + "Pincode " + Pincode + " is Repeating in Record-" + RepeateColumn; IsValid = false; } } if (IsValid) { DataTable dtAreaPincode = new Query() { Pincode = Pincode, eStatusNot = (int)eStatus.Delete }.Select(eSP.qry_Area); if (dtAreaPincode.Rows.Count > 0 && !chkReplace.Checked) { string Status = dtAreaPincode.Rows[0][CS.eStatus].zToInt().Value == (int)eStatus.Deactive ? "(Deactive)" : string.Empty; Message += CS.Arrow + Pincode + " Pincode is already exist" + Status + "." + Connecter; IsValid = false; } } } #endregion if (IsValid) { SuccessCount++; } else { FailCount++; if (FailCount >= 10) { break; } } } } catch (Exception ex) { CU.ZMessage(eMsgType.Error, string.Empty, ex.Message, 0); return(false); } if (FailCount == 0) { return(true); } else { CU.SetErrorExcelMessage(Message, SuccessCount, FailCount); return(false); } }