public dynamic Get_OrderDetails(HomeSearchModel model) { var orderModel = new List <EstimationModel>(); try { _dbContext.Configuration.AutoDetectChangesEnabled = false; var cultureId = new SqlParameter("Culture", model.CurrentCulture); var type = new SqlParameter("SearchType", model.Search.Type); var value = new SqlParameter("Value", model.Search.Value); IQueryable <EstimationModel> query = _dbContext.Database.SqlQuery <EstimationModel> ("EXEC SP_GetHomeSearchData @Culture, @SearchType, @Value", cultureId, type, value).AsQueryable(); orderModel = query.ToList(); //orderModel.ForEach(el => { el.EstimationStatusName = Enum.GetName(typeof(EstimationStatus), el.EstimationStatus); }); } catch (Exception ex) { IErrorLogService errorLog = new ErrorLogService(); string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; errorLog.SetErrorLog(model.CurrentUserID, "Home Search", message); throw new Exception(message); } finally { _dbContext.Configuration.AutoDetectChangesEnabled = true; } return(orderModel); }
public ActionResult Search(string query) { //ViewBag.DefaultCountry = MoneyHelper.DefaultCountry; //ViewBag.DefaultCurrency = MoneyHelper.DefaultCurrency; var model = new HomeSearchModel(); model.Search(query); return(View(model)); }
public HttpResponseMessage SearchClient(HomeSearchModel model) { try { var ret = _service.Get_ClientDetails(model); return(Request.CreateResponse(HttpStatusCode.OK, (object)ret)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public ActionResult <IEnumerable <Home> > Search([FromBody] HomeSearchModel model) { ActionResult <IEnumerable <Home> > result = db.Home.Include(p => p.ImageUrl).OrderByDescending(p => p.CreatedAt).ToList(); //Поиск когда заданы все 3 параметра if (model.City != "" && model.Street != "" && model.HomeNumber != "") { result = db.Home.Include(p => p.ImageUrl).Where(c => c.City == model.City && c.Street == model.Street && c.HomeNumber.Contains(model.HomeNumber)). OrderByDescending(p => p.CreatedAt).ToList(); } //иначе поиск по городу и улице else if (model.City != "" && model.Street != "") { result = db.Home.Include(p => p.ImageUrl).Where(c => c.City == model.City && c.Street == model.Street).OrderByDescending(p => p.CreatedAt).ToList(); } //иначе поиск по городу и номеру дома else if (model.City != "" && model.HomeNumber != "") { result = db.Home.Include(p => p.ImageUrl).Where(c => c.City == model.City && c.HomeNumber.Contains(model.HomeNumber)).OrderByDescending(p => p.CreatedAt).ToList(); } //иначе поиск по улице и номеру дома else if (model.Street != "" && model.HomeNumber != "") { result = db.Home.Include(p => p.ImageUrl).Where(c => c.Street == model.Street && c.HomeNumber.Contains(model.HomeNumber)).OrderByDescending(p => p.CreatedAt).ToList(); } //иначе поиск по одному параметру else { if (model.City != "") { result = db.Home.Include(p => p.ImageUrl).Where(c => c.City == model.City).OrderByDescending(p => p.CreatedAt).ToList(); } else if (model.Street != "") { result = db.Home.Include(p => p.ImageUrl).Where(c => c.Street == model.Street).OrderByDescending(p => p.CreatedAt).ToList(); } else if (model.HomeNumber != "") { result = db.Home.Include(p => p.ImageUrl).Where(c => c.HomeNumber.Contains(model.HomeNumber)).OrderByDescending(p => p.CreatedAt).ToList(); } } return(result); }
private void MenuUpdateHome_Click(object sender, RoutedEventArgs e) { try { ClearSearchResultsViews(); HomeSearchModel selectedHome = FoundHomesView.SelectedItem as HomeSearchModel; var homeID = selectedHome.HomeID; var ahw = new AddHomeWindow(); ahw.Show(); } catch (Exception ex) { DisplayStatusMessage("Select a Home first, then click Menu, Update Home."); logger.Data(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message); logger.Flush(); } finally { } }
public dynamic Get_StaffDetails(HomeSearchModel model) { SqlCommand cmd; SqlDataReader DataReader; List <object> lstObjRet = new List <object>(); try { _sqlConnService.OpenConnection(); cmd = new SqlCommand("SP_GetHomeSearchData", _sqlConnService.CreateConnection()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Culture", model.CurrentCulture); cmd.Parameters.AddWithValue("@SearchType", model.Search.Type); cmd.Parameters.AddWithValue("@Value", model.Search.Value); DataReader = cmd.ExecuteReader(); while (DataReader.Read() == true) { object row = new { Id = DataReader["Id"].ToString() }; lstObjRet.Add(row); } } catch (Exception ex) { IErrorLogService errorLog = new ErrorLogService(); string message = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message; throw new Exception(message); } finally { _sqlConnService.CloseConnection(); } return(lstObjRet); }