public IActionResult BestSeller(UserIndexPage model) { if (model.Search == null) { model.Search = ""; } if (model.Scale == null) { model.Scale = ""; } UserIndexPage uIP = new UserIndexPage { Search = model.Search, ListScale = new List <SelectListItem>() }; AddToComboBox(uIP, model.Scale); DataAccess data = new DataAccess(configuration); AzureCloud cloud = new AzureCloud(configuration); List <UserIndexPage> list = data.SearchProductBestSale(); foreach (UserIndexPage item in list) { item.Img += cloud.GetSAS(); } ViewBag.PList = list; return(View("Index", uIP)); }
public IActionResult Search(UserIndexPage model) { if (model.Search == null) { model.Search = ""; } if (model.Scale == null) { model.Scale = ""; } DataAccess data = new DataAccess(configuration); AzureCloud cloud = new AzureCloud(configuration); List <UserIndexPage> list = data.SearchProductByUser(model.Search, model.Scale); foreach (var item in list) { item.Img += cloud.GetSAS(); } UserIndexPage uIP = new UserIndexPage(); uIP.Search = model.Search; uIP.ListScale = new List <SelectListItem>(); AddToComboBox(uIP, model.Scale); if (list.Count == 0) { ViewBag.PList = null; } else { ViewBag.PList = list; } return(View(uIP)); }
public IActionResult Index() { DataAccess data = new DataAccess(configuration); AzureCloud cloud = new AzureCloud(configuration); List <UserIndexPage> list = data.SearchProductNewArrival(); foreach (UserIndexPage item in list) { item.Img += cloud.GetSAS(); } ViewBag.PList = list; UserIndexPage uIP = new UserIndexPage(); //null ref uIP.ListScale = new List <SelectListItem>(); AddToComboBox(uIP, ""); return(View(uIP)); }
private void AddToComboBox(UserIndexPage uIP, string scaleID) { DataAccess dataAccess = new DataAccess(configuration); List <Scale> list = dataAccess.GetAllScales(); foreach (var i in list) { SelectListItem t = new SelectListItem { Text = i.Name, Value = i.ID.ToString() }; if (i.ID.ToString().Equals(scaleID)) { t.Selected = true; } uIP.ListScale.Add(t); } }