private List<SelectListItem> BuildImageList(string currentfile) { // Get the account id int accountid = 0; if (Session["UserAccountID"] != null) accountid = Convert.ToInt32(Session["UserAccountID"]); // Get the active images IImageRepository imgrep = new EntityImageRepository(); IEnumerable<Image> imgs = imgrep.GetActiveImages(accountid); string imagefolder = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; List<SelectListItem> items = new List<SelectListItem>(); bool first = true; foreach (Image img in imgs) { if (first) { first = false; firstfile = imagefolder + img.StoredFilename; } SelectListItem item = new SelectListItem(); item.Text = img.ImageName; item.Value = img.StoredFilename; if (item.Value == currentfile) selectedfile = imagefolder + img.StoredFilename; items.Add(item); } return items; }
private List<SelectListItem> BuildImageList(int currentimageid) { // Get the account id int accountid = 0; if (Session["UserAccountID"] != null) accountid = Convert.ToInt32(Session["UserAccountID"]); // Get the active images IImageRepository imgrep = new EntityImageRepository(); IEnumerable<Image> imgs = imgrep.GetActiveImages(accountid); List<SelectListItem> items = new List<SelectListItem>(); if (currentimageid > 0) { Image currentimage = imgrep.GetImage(currentimageid); SelectListItem item = new SelectListItem(); item.Text = currentimage.ImageName; item.Value = currentimage.ImageID.ToString(); items.Add(item); } foreach (Image img in imgs) { SelectListItem item = new SelectListItem(); item.Text = img.ImageName; item.Value = img.ImageID.ToString(); items.Add(item); } return items; }