public JsonResult SearchAjax(string searchText) { var events = this.unitOfWork.EventRepository.Get(); List <SearchAjax> listevent = new List <SearchAjax>(); if (!String.IsNullOrEmpty(searchText)) { foreach (Event evt in events.ToList()) { var searchAjax = new SearchAjax { EventId = evt.EventId, Artist = evt.Artist, EventName = evt.EventName, EventImage = evt.EventImage, Status = evt.Status }; if (Utils.ConvertVN(evt.EventName).ToLower().Contains(Utils.ConvertVN(searchText).ToLower()) && (evt.Status == 3 || evt.Status == 1)) { listevent.Add(searchAjax); } else if (Utils.ConvertVN(evt.Artist == null ? "" : evt.Artist).ToLower().Contains(Utils.ConvertVN(searchText).ToLower()) && (evt.Status == 3 || evt.Status == 1)) { if (!listevent.Contains(searchAjax)) { listevent.Add(searchAjax); } } } } return(Json(listevent, JsonRequestBehavior.AllowGet)); }
protected void SaveButton_Click(object sender, System.EventArgs e) { if (Page.IsValid) { SaveManufacturer(); } ModalPopupExtender.Hide(); EditAjax.Update(); ManufacturerGrid.DataBind(); SearchAjax.Update(); }
protected void AddManufacturerButton_Click(object sender, EventArgs e) { if (Page.IsValid) { Manufacturer manufacturer = ManufacturerDataSource.LoadForName(AddManufacturerName.Text, false); // MANUFACTURER NAME SHOULD BE UNIQUE if (manufacturer != null) { AddManufacturerNameRequired.IsValid = false; AddManufacturerNameRequired.ErrorMessage = "The manufacturer with name \"" + AddManufacturerName.Text + "\" already exists."; return; } manufacturer = new Manufacturer(); manufacturer.Name = AddManufacturerName.Text; manufacturer.Save(); AddManufacturerName.Text = String.Empty; AddedMessage.Text = string.Format((string)ViewState["AddedMessage.Text"], manufacturer.Name); AddedMessage.Visible = true; ManufacturerGrid.DataBind(); SearchAjax.Update(); } }