//Get Home section of the Website public HomeQuery getHome() { try { HomeQuery home = new HomeQuery(); home.homeMainTitle = this.getInterfaceElement("homeMainTitle").content; home.homeParagraph1 = this.getInterfaceElement("homeParagraph1").content; return home; } catch (Exception ex) { Console.Write("WebManager.getHome error " + ex); return null; } }
//Get Image found in the Home section of the website public HomeQuery getHomeImage() { try { HomeQuery home = new HomeQuery(); using (conferenceadminContext context = new conferenceadminContext()) { //Get element and save its content var img = (from s in context.interfacedocuments where s.attibuteName == "homeImage" select s).FirstOrDefault(); if (img != null) { home.image = img.content; } } return home; } catch (Exception ex) { Console.Write("WebManager.getHomeImage error " + ex); return null; } }
//Update content of the Home section of the website public bool saveHome(HomeQuery newHome) { try { using (conferenceadminContext context = new conferenceadminContext()) { this.saveInterfaceElement("homeMainTitle", newHome.homeMainTitle); this.saveInterfaceElement("homeParagraph1", newHome.homeParagraph1); //Get image element var img = (from s in context.interfacedocuments where s.attibuteName == "homeImage" select s).FirstOrDefault(); //Save new content if (img != null && newHome.image != null && newHome.image != "") img.content = newHome.image; context.SaveChanges(); return true; } } catch (Exception ex) { Console.Write("WebManager.saveHome error " + ex); return false; } }