private void ShowCarPartsContent() { // get data. List <CarPartDetails> data = new CarPartsManager().GetAllCarPartsForWebSite().Take(10).ToList(); maxPrice = data.Max(x => x.Price); minPrice = data.Min(x => x.Price); Session["maxPrice"] = Convert.ToDecimal(maxPrice); Session["cur_maxPrice"] = Convert.ToDecimal(maxPrice); Session["cur_minPrice"] = Convert.ToDecimal(1); parts = data; if (data != null) { foreach (var item in data) { var model = new CarPartsImagesManager().CarPartHasMainImage(item.CarPartId); if (model.Count() == 0) { item.ImageUrl = "20_bQT1WmUM.jpg"; } else { item.ImageUrl = model.Where(x => x.IsMain == true).FirstOrDefault().Url; } } } }
private void ShowCarPartsContent() { // get data. var data = new CarPartsManager().GetAllCarParts(); if (data != null) { foreach (var item in data) { var model = new CarPartsImagesManager().CarPartHasMainImage(item.CarPartId); if (model.Count() == 0) { item.ImageUrl = "20_bQT1WmUM.jpg"; } else { var model0 = model.Where(x => x.IsMain == true).ToList(); if (model0.Count() == 0) { item.ImageUrl = "20_bQT1WmUM.jpg"; } else { item.ImageUrl = model0.FirstOrDefault().Url; } } } // show home news lvCarParts.DataSource = data; lvCarParts.DataBind(); } FillLists.FillCarPartTypesList(ddlcarPartType); }
private void ShowCarPartsContentWithSearchAndCarPartType(int id) { // get data. var data = new CarPartsManager().GetAllCarPartsBycarPartType(txtName.Text.Trim(), id); if (data != null) { foreach (var item in data) { var model = new CarPartsImagesManager().CarPartHasMainImage(item.CarPartId); if (model.Count() == 0) { item.ImageUrl = "20_bQT1WmUM.jpg"; } else { item.ImageUrl = model.Where(x => x.IsMain == true).FirstOrDefault().Url; } } // show home news lvCarParts.DataSource = data; lvCarParts.DataBind(); } }
private void ShowCarPartsContentWithSearch() { CarPartsSearch model = new CarPartsSearch(); if (ddlMarkers.SelectedIndex > 0) { model.MakerId = Convert.ToInt32(ddlMarkers.SelectedValue); } if (ddlModels.SelectedIndex > 0) { model.ModelId = Convert.ToInt32(ddlModels.SelectedValue); } if (ddlcarPartType.SelectedIndex > 0) { model.CarPartTypeId = Convert.ToInt32(ddlcarPartType.SelectedValue); } if (ddlYears.SelectedIndex > 0) { model.FromYearId = Convert.ToInt32(ddlYears.SelectedItem.Text); } if (ddlToYears.SelectedIndex > 0) { model.ToYearId = Convert.ToInt32(ddlToYears.SelectedItem.Text); } model.Search = txtName.Text.Trim(); string _price = amout_rating.Value.ToString(); model.StartPrice = Convert.ToDecimal(_price.Split(',')[0]); model.EndPrice = Convert.ToDecimal(_price.Split(',')[1]); Session["cur_minPrice"] = Convert.ToDecimal(model.StartPrice); Session["cur_maxPrice"] = Convert.ToDecimal(model.EndPrice); List <CarPartDetails> data = new List <CarPartDetails>(); // get data. int page = Convert.ToInt32(pagenum.Value); page++; pagenum.Value = page.ToString(); data = new CarPartsManager().GetAllCarParts(model).Take(page * 10).ToList(); parts = data; if (data != null) { foreach (var item in data) { var model0 = new CarPartsImagesManager().CarPartHasMainImage(item.CarPartId); if (model0.Count() == 0) { item.ImageUrl = "20_bQT1WmUM.jpg"; } else { item.ImageUrl = model0.Where(x => x.IsMain == true).FirstOrDefault().Url; } } } }
private void ShowCarPartsContentWithSearch() { var data = new List <CarPartDetails>(); // get data. int selectedindex = Convert.ToInt32(ddlcarPartType.SelectedIndex); if (selectedindex > 0) { data = new CarPartsManager().GetAllCarPartsBycarPartType(txtName.Text.Trim(), selectedindex); } else { data = new CarPartsManager().GetAllCarParts(txtName.Text.Trim()); } if (data != null) { foreach (var item in data) { var model = new CarPartsImagesManager().CarPartHasMainImage(item.CarPartId); if (model.Count() == 0) { item.ImageUrl = "20_bQT1WmUM.jpg"; } else { item.ImageUrl = model.Where(x => x.IsMain == true).FirstOrDefault().Url; } } // show home news lvCarParts.DataSource = data; lvCarParts.DataBind(); } FillLists.FillCarPartTypesList(ddlcarPartType); if (selectedindex > 0) { ddlcarPartType.SelectedValue = selectedindex.ToString(); } }