public static void LoadLogo() { websiteImages dal = new websiteImages(); List <adminPhoto> lst = (from x in dal.pLst where x.type.Equals("Logo") select x).ToList <adminPhoto>(); try { image = lst[0].image; }catch (Exception e) { } }
public ActionResult Index() { TempData["LogMess"] = ""; if (Session["connected"] == null) { Session["connected"] = "0"; } websiteImages dal = new websiteImages(); List <adminPhoto> ps = (from x in dal.pLst where x.type.Equals("Background") select x).ToList <adminPhoto>(); return(View(ps)); }
public ActionResult changeLogo(HttpPostedFileBase file) { byte[] data; using (Stream inputStram = file.InputStream) { MemoryStream memorystram = inputStram as MemoryStream; if (memorystram == null) { memorystram = new MemoryStream(); inputStram.CopyTo(memorystram); } websiteImages dal = new websiteImages(); adminPhoto p = new adminPhoto(); int size = (from x in dal.pLst where x.type.Equals("Logo") select x).ToList <adminPhoto>().Count(); if (size > 0) { dal.pLst.RemoveRange(dal.pLst.Where(x => x.type.Equals("Logo"))); try { dal.SaveChanges(); } catch (Exception e) { return(RedirectToAction("photoChange")); } } data = memorystram.ToArray(); p.type = "Logo"; p.image = data; dal.pLst.Add(p); try { dal.SaveChanges(); } catch (Exception e) { } } Moments.Controllers.HomeController.LoadLogo(); return(RedirectToAction("photoChange")); }