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 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 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 ShowCarPartsContent(int id) { // get data. CarPartDetails data = new CarPartsManager().GetCarPartDetailsById(id).FirstOrDefault(); if (data != null) { part = data; Page.Title = string.Format("{0} - {1} - {2} - {3}", part.MarkerNameEn, part.ModelNameEn, part.Year, part.CarPartType); part.ImagesUrl = new CarPartsImagesManager().GetAllImagesUrl(id); } }
private void SaveCarInformation() { CarPart CarToSave = new CarPart(); try { if (hfID.Value != "") { CarToSave.Id = Convert.ToInt32(hfID.Value); } CarToSave.IsActive = cbActive.Checked; //CarToSave.main_picture if (ddlMarkers.SelectedIndex > 0) { CarToSave.MakerId = Convert.ToInt32(ddlMarkers.SelectedValue); } if (ddlModels.SelectedIndex > 0) { CarToSave.ModelId = Convert.ToInt32(ddlModels.SelectedValue); } if (ddlcarPartType.SelectedIndex > 0) { CarToSave.TypeId = Convert.ToInt32(ddlcarPartType.SelectedValue); } if (txtSalePrice.Text != "") { CarToSave.Price = Convert.ToDecimal(txtSalePrice.Text); } //if (txtPriority.Text != "") { CarToSave.Periority = Convert.ToInt32(txtPriority.Text); } if (txtDesc.Text != "") { CarToSave.Description = txtDesc.Text; } if (ddlYears.SelectedIndex > 0) { CarToSave.YearId = Convert.ToInt32(ddlYears.SelectedValue); } var result = new CarPartsManager().SaveCarPart(CarToSave); if (result != null) { //go to Cars images list. string url = ResolveClientUrl("CarPartsImages.aspx?categoryType=cars&masterId=") + result; //"CarsView.aspx"; Response.Redirect(url); } else { lblError.Text = Resources.AdminResources_en.ErrorSave; } } catch { lblError.Text = Resources.AdminResources_en.ErrorSave; } }
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(); } }
private void ShowCarPartInformation(int Id) { var result = new CarPartsManager().GetCarPartById(Id); if (result != null) { cbActive.Checked = (bool)result.IsActive; if (result.MakerId != null) { ddlMarkers.SelectedValue = result.ModelId.ToString(); } ddlMarkers_SelectedIndexChanged(ddlMarkers, new EventArgs()); if (result.ModelId != null) { ddlModels.SelectedValue = result.ModelId.ToString(); } if (result.Year != null) { ddlYears.SelectedValue = result.YearId.ToString(); } if (result.CarPartType != null) { ddlcarPartType.SelectedValue = result.TypeId.ToString(); } if (result.Price != null) { txtSalePrice.Text = result.Price.ToString(); } //if (result.Periority != null) { txtPriority.Text = result.Periority.ToString(); } if (result.Description != null) { txtDesc.Text = result.Description.ToString(); } } }