// // GET: /Survey/Approve/5 public ActionResult Approve(int id) { try { if (Session["UserAccountID"] == null) return RedirectToAction("Validate", "Login"); User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) ViewData["txtIsAdmin"] = "true"; else ViewData["txtIsAdmin"] = "false"; Survey survey = repository.GetSurvey(id); ViewData["ValidationMessage"] = String.Empty; IImageRepository imgrep = new EntityImageRepository(); Image img = imgrep.GetImage(survey.SurveyImageID); ViewData["ImageList"] = new SelectList(BuildImageList(img.StoredFilename), "Value", "Text", img.StoredFilename); ViewData["ImageUrl"] = selectedfile; ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; ViewData["SurveyTable"] = BuildSurveyTableNoLinks(survey); return View(survey); } catch (Exception ex) { Helpers.SetupApplicationError("Survey", "Approve", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }
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; }
public string Player_GetMediaToDownload(int accountid) { try { IImageRepository imagerep = new EntityImageRepository(); IVideoRepository videorep = new EntityVideoRepository(); IMusicRepository musicrep = new EntityMusicRepository(); // Returns all the media files for the account List<Image> images = new List<Image>(); List<Video> videos = new List<Video>(); List<Music> musics = new List<Music>(); StringBuilder sb = new StringBuilder(); sb.Append("<xml>"); // Images --------------------------------------------------------------------------------- images = imagerep.GetAllImages(accountid).ToList(); sb.Append("<Images>"); foreach (Image image in images) { sb.Append("<Image "); sb.Append("ImageID=\"" + image.ImageID.ToString() + "\" "); sb.Append("StoredFilename=\"" + image.StoredFilename + "\" "); sb.Append("ImageName=\"" + Utility.EncodeXMLString(image.ImageName) + "\" "); sb.Append(" />"); } sb.Append("</Images>"); // Videos --------------------------------------------------------------------------------- videos = videorep.GetAllVideos(accountid).ToList(); sb.Append("<Videos>"); foreach (Video video in videos) { sb.Append("<Video "); sb.Append("VideoID=\"" + video.VideoID.ToString() + "\" "); sb.Append("StoredFilename=\"" + video.StoredFilename + "\" "); sb.Append("VideoName=\"" + video.VideoName + "\" "); sb.Append(" />"); } sb.Append("</Videos>"); // Music --------------------------------------------------------------------------------- musics = musicrep.GetAllMusics(accountid).ToList(); sb.Append("<Musics>"); foreach (Music music in musics) { sb.Append("<Music "); sb.Append("MusicID=\"" + music.MusicID.ToString() + "\" "); sb.Append("StoredFilename=\"" + music.StoredFilename + "\" "); sb.Append("MusicName=\"" + music.MusicName + "\" "); sb.Append(" />"); } sb.Append("</Musics>"); // Close the XML and return sb.Append("</xml>"); return sb.ToString(); } catch (Exception ex) { return "<xml><Error>" + ex.Message + "</Error></xml>"; } }
public ActionResult Edit(Survey survey) { try { if (Session["UserAccountID"] == null) return RedirectToAction("Validate", "Login"); User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) ViewData["txtIsAdmin"] = "true"; else ViewData["txtIsAdmin"] = "false"; if (ModelState.IsValid) { // Set NULLs to Empty Strings survey = FillNulls(survey); IImageRepository imgrep = new EntityImageRepository(); Image img = imgrep.GetImageByGuid(Request.Form["lstImage"]); if (img != null) survey.SurveyImageID = img.ImageID; else survey.SurveyImageID = 0; string validation = ValidateInput(survey); if (!String.IsNullOrEmpty(validation)) { ViewData["ValidationMessage"] = validation; ViewData["ImageList"] = new SelectList(BuildImageList(Request.Form["lstImage"]), "Value", "Text", Request.Form["lstImage"]); ViewData["ImageUrl"] = selectedfile; ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; ViewData["SurveyTable"] = BuildSurveyTable(survey); return View(survey); } repository.UpdateSurvey(survey); CommonMethods.CreateActivityLog((User)Session["User"], "Survey", "Edit", "Edited survey '" + survey.SurveyName + "' - ID: " + survey.SurveyID.ToString()); return RedirectToAction("Index"); } return View(survey); } catch (Exception ex) { Helpers.SetupApplicationError("Survey", "Edit POST", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }
public ActionResult Create(SlideShow slideshow) { try { if (Session["UserAccountID"] == null) return RedirectToAction("Validate", "Login"); User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) ViewData["txtIsAdmin"] = "true"; else ViewData["txtIsAdmin"] = "false"; if (ModelState.IsValid) { // Set NULLs to Empty Strings slideshow = FillNulls(slideshow); slideshow.AccountID = Convert.ToInt32(Session["UserAccountID"]); string validation = ValidateInput(slideshow, Request.Form["txtSlideShowImages"].ToString()); if (!String.IsNullOrEmpty(validation)) { ViewData["ValidationMessage"] = validation; ViewData["ImageList"] = new SelectList(BuildImageList(), "Value", "Text", ""); ViewData["MusicList"] = new SelectList(BuildMusicList(), "Value", "Text", ""); ViewData["ImageUrl"] = firstfile; ViewData["SlideShowImages"] = Request.Form["txtSlideShowImages"].ToString(); ViewData["MusicImages"] = Request.Form["txtSlideShowMusic"].ToString(); ViewData["SlideShowImageList"] = new SelectList(BuildSlideShowImageList(Request.Form["txtSlideShowImages"].ToString()), "Value", "Text", ""); ViewData["SlideShowMusicList"] = new SelectList(BuildSlideShowMusicList(Request.Form["txtSlideShowMusic"].ToString()), "Value", "Text", ""); ViewData["TransitionTypeList"] = new SelectList(BuildTransitionTypeList(), "Value", "Text", Request.Form["lstTransitionType"].ToString()); // Get the account id int accountid = 0; if (Session["UserAccountID"] != null) accountid = Convert.ToInt32(Session["UserAccountID"]); ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; return View(slideshow); } else { // Create the slideshow slideshow.TransitionType = Request.Form["lstTransitionType"].ToString(); repository.CreateSlideShow(slideshow); CommonMethods.CreateActivityLog((User)Session["User"], "Slide Show", "Add", "Added slide show '" + slideshow.SlideShowName + "' - ID: " + slideshow.SlideShowID.ToString()); ISlideShowImageXrefRepository xrefrep = new EntitySlideShowImageXrefRepository(); ISlideShowMusicXrefRepository musicxrefrep = new EntitySlideShowMusicXrefRepository(); IImageRepository imgrep = new EntityImageRepository(); IMusicRepository musicrep = new EntityMusicRepository(); // Create a xref for each image in the slideshow string[] guids = Request.Form["txtSlideShowImages"].ToString().Split('|'); int i = 1; foreach (string guid in guids) { if (!String.IsNullOrEmpty(guid.Trim())) { Image img = imgrep.GetImageByGuid(guid); if (img != null) { SlideShowImageXref xref = new SlideShowImageXref(); xref.PlayOrder = i; xref.SlideShowID = slideshow.SlideShowID; xref.ImageID = img.ImageID; xrefrep.CreateSlideShowImageXref(xref); i += 1; } } } // Create a xref for each music file in the slideshow guids = Request.Form["txtSlideShowMusic"].ToString().Split('|'); i = 1; foreach (string guid in guids) { if (!String.IsNullOrEmpty(guid.Trim())) { Music music = musicrep.GetMusicByGuid(guid); if (music != null) { SlideShowMusicXref xref = new SlideShowMusicXref(); xref.PlayOrder = i; xref.SlideShowID = slideshow.SlideShowID; xref.MusicID = music.MusicID; musicxrefrep.CreateSlideShowMusicXref(xref); i += 1; } } } return RedirectToAction("Index"); } } return View(slideshow); } catch (Exception ex) { Helpers.SetupApplicationError("SlideShow", "Create POST", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }
public string Player_GetCurrentSchedule(int playerid) { try { IImageRepository imagerep = new EntityImageRepository(); IPlayerRepository playerrep = new EntityPlayerRepository(); IPlayerGroupScheduleRepository playergroupschedulerep = new EntityPlayerGroupScheduleRepository(); IPlayListRepository playlistrep = new EntityPlayListRepository(); IPlayListVideoXrefRepository playlistvideoxrefrep = new EntityPlayListVideoXrefRepository(); IScreenScreenContentXrefRepository screenscreencontentxrefrep = new EntityScreenScreenContentXrefRepository(); IScreenContentRepository screencontentrep = new EntityScreenContentRepository(); IScreenContentTypeRepository screencontenttyperep = new EntityScreenContentTypeRepository(); IScreenRepository screenrep = new EntityScreenRepository(); ISlideShowRepository slideshowrep = new EntitySlideShowRepository(); ISlideShowImageXrefRepository slideshowimagexrefrep = new EntitySlideShowImageXrefRepository(); ISlideShowMusicXrefRepository slideshowmusicxrefrep = new EntitySlideShowMusicXrefRepository(); ISurveyRepository surveyrep = new EntitySurveyRepository(); ISurveyQuestionRepository surveyquestionrep = new EntitySurveyQuestionRepository(); ISurveyQuestionOptionRepository surveyquestionoptionrep = new EntitySurveyQuestionOptionRepository(); IVideoRepository videorep = new EntityVideoRepository(); IMusicRepository musicrep = new EntityMusicRepository(); // returns the summarized schedule information for the player List<Image> images = new List<Image>(); List<PlayerGroupSchedule> playergroupschedules = new List<PlayerGroupSchedule>(); List<PlayList> playlists = new List<PlayList>(); List<PlayListVideoXref> playlistvideoxrefs = new List<PlayListVideoXref>(); List<ScreenContent> screencontents = new List<ScreenContent>(); List<ScreenScreenContentXref> screenscreencontentxrefs = new List<ScreenScreenContentXref>(); List<Screen> screens = new List<Screen>(); List<SlideShow> slideshows = new List<SlideShow>(); List<SlideShowImageXref> slideshowimagexrefs = new List<SlideShowImageXref>(); List<SlideShowMusicXref> slideshowmusicxrefs = new List<SlideShowMusicXref>(); List<Survey> surveys = new List<Survey>(); List<SurveyQuestion> surveyquestions = new List<SurveyQuestion>(); List<SurveyQuestionOption> surveyquestionoptions = new List<SurveyQuestionOption>(); List<Video> videos = new List<Video>(); List<Music> musics = new List<Music>(); StringBuilder sb = new StringBuilder(); sb.Append("<xml>"); // Player Schedule Info -------------------------------------------------------------------------------------- // Get the PlayerGroupID - Player should only exist in one Player Group Player player = playerrep.GetPlayer(playerid); if (player == null) throw new Exception("No player found."); // Get the PlayerGroupSchedule for this player playergroupschedules = playergroupschedulerep.GetPlayerGroupSchedulesByPlayerGroup(player.PlayerGroupID).ToList(); if (playergroupschedules == null || playergroupschedules.Count == 0) throw new Exception("No schedule found for this player."); sb.Append("<PlayerGroupSchedules>"); foreach (PlayerGroupSchedule playergroupschedule in playergroupschedules) { sb.Append("<PlayerGroupSchedule "); sb.Append("PlayerGroupScheduleID=\"" + playergroupschedule.PlayerGroupScheduleID.ToString() + "\" "); sb.Append("PlayerGroupID=\"" + playergroupschedule.PlayerGroupID.ToString() + "\" "); sb.Append("ScreenID=\"" + playergroupschedule.ScreenID.ToString() + "\" "); sb.Append("Day=\"" + playergroupschedule.Day.ToString() + "\" "); sb.Append("Hour=\"" + playergroupschedule.Hour.ToString() + "\" "); sb.Append("Minute=\"" + playergroupschedule.Minute.ToString() + "\" "); sb.Append(" />"); // Add the screen to the screens list screens.Add(screenrep.GetScreen(playergroupschedule.ScreenID)); } sb.Append("</PlayerGroupSchedules>"); // Screens -------------------------------------------------------------------------------------- screens = screens.Distinct().ToList(); sb.Append("<Screens>"); foreach (Screen screen in screens) { sb.Append("<Screen "); sb.Append("ScreenID=\"" + screen.ScreenID.ToString() + "\" "); sb.Append("AccountID=\"" + screen.AccountID.ToString() + "\" "); sb.Append("ScreenName=\"" + Utility.EncodeXMLString(screen.ScreenName) + "\" "); sb.Append("SlideShowID=\"" + screen.SlideShowID.ToString() + "\" "); sb.Append("PlayListID=\"" + screen.PlayListID.ToString() + "\" "); string interactive = "true"; if (!screen.IsInteractive) interactive = "false"; sb.Append("IsInteractive=\"" + interactive + "\" "); sb.Append("ButtonImageID=\"" + screen.ButtonImageID.ToString() + "\" "); sb.Append(" />"); // Save the SlideShow if (screen.SlideShowID != 0) slideshows.Add(slideshowrep.GetSlideShow(screen.SlideShowID)); // Save the PlayList if (screen.PlayListID != 0) playlists.Add(playlistrep.GetPlayList(screen.PlayListID)); // Save the screen button image if (screen.ButtonImageID != 0) images.Add(imagerep.GetImage(screen.ButtonImageID)); // Save the ScreenContentXrefs List<ScreenScreenContentXref> sscxrefs = screenscreencontentxrefrep.GetScreenScreenContentXrefs(screen.ScreenID).ToList(); foreach (ScreenScreenContentXref sscxref in sscxrefs) { // Save to the xref screenscreencontentxrefs.Add(sscxref); } } sb.Append("</Screens>"); // ScreenScreenContentXrefs ----------------------------------------------------------------------------- sb.Append("<ScreenScreenContentXrefs>"); foreach (ScreenScreenContentXref sscxref in screenscreencontentxrefs) { sb.Append("<ScreenScreenContentXref "); sb.Append("ScreenScreenContentXrefID=\"" + sscxref.ScreenScreenContentXrefID.ToString() + "\" "); sb.Append("ScreenID=\"" + sscxref.ScreenID.ToString() + "\" "); sb.Append("ScreenContentID=\"" + sscxref.ScreenContentID.ToString() + "\" "); sb.Append("DisplayOrder=\"" + sscxref.DisplayOrder.ToString() + "\" "); sb.Append(" />"); // Save the screen content screencontents.Add(screencontentrep.GetScreenContent(sscxref.ScreenContentID)); } sb.Append("</ScreenScreenContentXrefs>"); // ScreenContents ------------------------------------------------------------------------------------- screencontents = screencontents.Distinct().ToList(); sb.Append("<ScreenContents>"); foreach (ScreenContent sc in screencontents) { ScreenContentType sctype = screencontenttyperep.GetScreenContentType(sc.ScreenContentTypeID); sb.Append("<ScreenContent "); sb.Append("ScreenContentID=\"" + sc.ScreenContentID.ToString() + "\" "); sb.Append("ScreenContentTypeID=\"" + sc.ScreenContentTypeID.ToString() + "\" "); sb.Append("ScreenContentTypeName=\"" + Utility.EncodeXMLString(sctype.ScreenContentTypeName) + "\" "); sb.Append("ScreenContentName=\"" + Utility.EncodeXMLString(sc.ScreenContentName) + "\" "); sb.Append("ScreenContentTitle=\"" + Utility.EncodeXMLString(sc.ScreenContentTitle) + "\" "); sb.Append("ThumbnailImageID=\"" + sc.ThumbnailImageID.ToString() + "\" "); sb.Append("CustomField1=\"" + Utility.EncodeXMLString(sc.CustomField1) + "\" "); sb.Append("CustomField2=\"" + Utility.EncodeXMLString(sc.CustomField2) + "\" "); sb.Append("CustomField3=\"" + Utility.EncodeXMLString(sc.CustomField3) + "\" "); sb.Append("CustomField4=\"" + Utility.EncodeXMLString(sc.CustomField4) + "\" "); sb.Append(" />"); // Add the Thumbnail Image if (sc.ThumbnailImageID != 0) images.Add(imagerep.GetImage(sc.ThumbnailImageID)); // If Image, add the image if (sc.ScreenContentTypeID == 1000000 && !String.IsNullOrEmpty(sc.CustomField1)) images.Add(imagerep.GetImage(Convert.ToInt32(sc.CustomField1))); // If Slideshow, add the slideshow if (sc.ScreenContentTypeID == 1000001 && !String.IsNullOrEmpty(sc.CustomField1)) slideshows.Add(slideshowrep.GetSlideShow(Convert.ToInt32(sc.CustomField1))); // If Video, add the video if (sc.ScreenContentTypeID == 1000002 && !String.IsNullOrEmpty(sc.CustomField1)) videos.Add(videorep.GetVideo(Convert.ToInt32(sc.CustomField1))); // If PlayList, add the playlist if (sc.ScreenContentTypeID == 1000003 && !String.IsNullOrEmpty(sc.CustomField1)) playlists.Add(playlistrep.GetPlayList(Convert.ToInt32(sc.CustomField1))); // If Survey, add the survey and its image if (sc.ScreenContentTypeID == 1000007 && !String.IsNullOrEmpty(sc.CustomField1)) { Survey survey = surveyrep.GetSurvey(Convert.ToInt32(sc.CustomField1)); images.Add(imagerep.GetImage(survey.SurveyImageID)); surveys.Add(survey); } } sb.Append("</ScreenContents>"); // Surveys --------------------------------------------------------------------------------- surveys = surveys.Distinct().ToList(); sb.Append("<Surveys>"); foreach (Survey sv in surveys) { sb.Append("<Survey "); sb.Append("SurveyID=\"" + sv.SurveyID + "\" "); sb.Append("SurveyName=\"" + Utility.EncodeXMLString(sv.SurveyName) + "\" "); sb.Append("SurveyImageID=\"" + sv.SurveyImageID + "\" "); sb.Append(" />"); List<SurveyQuestion> svqs = surveyquestionrep.GetSurveyQuestions(sv.SurveyID).ToList(); foreach (SurveyQuestion svq in svqs) { surveyquestions.Add(svq); } } sb.Append("</Surveys>"); // SurveyQuestions ---------------------------------------------------------------------------- surveyquestions = surveyquestions.Distinct().ToList(); sb.Append("<SurveyQuestions>"); foreach (SurveyQuestion svq in surveyquestions) { sb.Append("<SurveyQuestion "); sb.Append("SurveyQuestionID=\"" + svq.SurveyQuestionID + "\" "); sb.Append("SurveyID=\"" + svq.SurveyID + "\" "); sb.Append("SurveyQuestionText=\"" + Utility.EncodeXMLString(svq.SurveyQuestionText) + "\" "); sb.Append("AllowMultiselect=\"" + svq.AllowMultiSelect.ToString() + "\" "); sb.Append("SortOrder=\"" + svq.SortOrder.ToString() + "\" "); sb.Append(" />"); List<SurveyQuestionOption> svqos = surveyquestionoptionrep.GetSurveyQuestionOptions(svq.SurveyQuestionID).ToList(); foreach (SurveyQuestionOption svqo in svqos) { surveyquestionoptions.Add(svqo); } } sb.Append("</SurveyQuestions>"); // SurveyQuestionOptions ---------------------------------------------------------------------------- surveyquestionoptions = surveyquestionoptions.Distinct().ToList(); sb.Append("<SurveyQuestionOptions>"); foreach (SurveyQuestionOption svqo in surveyquestionoptions) { sb.Append("<SurveyQuestionOption "); sb.Append("SurveyQuestionOptionID=\"" + svqo.SurveyQuestionOptionID + "\" "); sb.Append("SurveyQuestionID=\"" + svqo.SurveyQuestionID + "\" "); sb.Append("SurveyQuestionOptionText=\"" + Utility.EncodeXMLString(svqo.SurveyQuestionOptionText) + "\" "); sb.Append("SortOrder=\"" + svqo.SortOrder.ToString() + "\" "); sb.Append(" />"); } sb.Append("</SurveyQuestionOptions>"); // SlideShows --------------------------------------------------------------------------------- slideshows = slideshows.Distinct().ToList(); sb.Append("<SlideShows>"); foreach (SlideShow ss in slideshows) { sb.Append("<SlideShow "); sb.Append("SlideShowID=\"" + ss.SlideShowID.ToString() + "\" "); sb.Append("IntervalInSecs=\"" + ss.IntervalInSecs.ToString() + "\" "); sb.Append("TransitionType=\"" + Utility.EncodeXMLString(ss.TransitionType) + "\" "); sb.Append(" />"); List<SlideShowImageXref> ssixrefs = slideshowimagexrefrep.GetSlideShowImageXrefs(ss.SlideShowID).ToList(); foreach (SlideShowImageXref ssixref in ssixrefs) { slideshowimagexrefs.Add(ssixref); } List<SlideShowMusicXref> ssmxrefs = slideshowmusicxrefrep.GetSlideShowMusicXrefs(ss.SlideShowID).ToList(); foreach (SlideShowMusicXref ssmxref in ssmxrefs) { slideshowmusicxrefs.Add(ssmxref); } } sb.Append("</SlideShows>"); // SlideshowImageXrefs --------------------------------------------------------------------------------- slideshowimagexrefs = slideshowimagexrefs.Distinct().ToList(); sb.Append("<SlideShowImageXrefs>"); foreach (SlideShowImageXref ssixref in slideshowimagexrefs) { sb.Append("<SlideShowImageXref "); sb.Append("SlideShowImageXrefID=\"" + ssixref.SlideShowImageXrefID.ToString() + "\" "); sb.Append("SlideShowID=\"" + ssixref.SlideShowID.ToString() + "\" "); sb.Append("ImageID=\"" + ssixref.ImageID.ToString() + "\" "); sb.Append("PlayOrder=\"" + ssixref.PlayOrder.ToString() + "\" "); sb.Append(" />"); // Add the image images.Add(imagerep.GetImage(ssixref.ImageID)); } sb.Append("</SlideShowImageXrefs>"); // SlideshowMusicXrefs --------------------------------------------------------------------------------- slideshowmusicxrefs = slideshowmusicxrefs.Distinct().ToList(); sb.Append("<SlideShowMusicXrefs>"); foreach (SlideShowMusicXref ssmxref in slideshowmusicxrefs) { sb.Append("<SlideShowMusicXref "); sb.Append("SlideShowMusicXrefID=\"" + ssmxref.SlideShowMusicXrefID.ToString() + "\" "); sb.Append("SlideShowID=\"" + ssmxref.SlideShowID.ToString() + "\" "); sb.Append("MusicID=\"" + ssmxref.MusicID.ToString() + "\" "); sb.Append("PlayOrder=\"" + ssmxref.PlayOrder.ToString() + "\" "); sb.Append(" />"); // Add the music musics.Add(musicrep.GetMusic(ssmxref.MusicID)); } sb.Append("</SlideShowMusicXrefs>"); // Images --------------------------------------------------------------------------------- images = images.Distinct().ToList(); sb.Append("<Images>"); foreach (Image image in images) { sb.Append("<Image "); sb.Append("ImageID=\"" + image.ImageID.ToString() + "\" "); sb.Append("StoredFilename=\"" + image.StoredFilename + "\" "); sb.Append("ImageName=\"" + Utility.EncodeXMLString(image.ImageName) + "\" "); sb.Append(" />"); } sb.Append("</Images>"); // PlayLists --------------------------------------------------------------------------------- playlists = playlists.Distinct().ToList(); sb.Append("<PlayLists>"); foreach (PlayList pl in playlists) { sb.Append("<PlayList "); sb.Append("PlayListID=\"" + pl.PlayListID.ToString() + "\" "); sb.Append(" />"); List<PlayListVideoXref> plvxrefs = playlistvideoxrefrep.GetPlayListVideoXrefs(pl.PlayListID).ToList(); foreach (PlayListVideoXref plvxref in plvxrefs) { playlistvideoxrefs.Add(plvxref); } } sb.Append("</PlayLists>"); // PlaylistVideoXrefs --------------------------------------------------------------------------------- playlistvideoxrefs = playlistvideoxrefs.Distinct().ToList(); sb.Append("<PlayListVideoXrefs>"); foreach (PlayListVideoXref plvxref in playlistvideoxrefs) { sb.Append("<PlayListVideoXref "); sb.Append("PlayListVideoXrefID=\"" + plvxref.PlayListVideoXrefID.ToString() + "\" "); sb.Append("PlayListID=\"" + plvxref.PlayListID.ToString() + "\" "); sb.Append("VideoID=\"" + plvxref.VideoID.ToString() + "\" "); sb.Append("PlayOrder=\"" + plvxref.PlayOrder.ToString() + "\" "); sb.Append(" />"); videos.Add(videorep.GetVideo(plvxref.VideoID)); } sb.Append("</PlayListVideoXrefs>"); // Videos --------------------------------------------------------------------------------- videos = videos.Distinct().ToList(); sb.Append("<Videos>"); foreach (Video video in videos) { sb.Append("<Video "); sb.Append("VideoID=\"" + video.VideoID.ToString() + "\" "); sb.Append("StoredFilename=\"" + video.StoredFilename + "\" "); sb.Append("VideoName=\"" + video.VideoName + "\" "); sb.Append(" />"); } sb.Append("</Videos>"); // Musics --------------------------------------------------------------------------------- musics = musics.Distinct().ToList(); sb.Append("<Musics>"); foreach (Music music in musics) { sb.Append("<Music "); sb.Append("MusicID=\"" + music.MusicID.ToString() + "\" "); sb.Append("StoredFilename=\"" + music.StoredFilename + "\" "); sb.Append("MusicName=\"" + music.MusicName + "\" "); sb.Append(" />"); } sb.Append("</Musics>"); // Close the XML and return sb.Append("</xml>"); return sb.ToString(); } catch (Exception ex) { return "<xml><Error>" + ex.Message + "</Error></xml>"; } }
// // GET: /SlideShow/Edit/5 public ActionResult Edit(int id) { try { if (Session["UserAccountID"] == null) return RedirectToAction("Validate", "Login"); User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) ViewData["txtIsAdmin"] = "true"; else ViewData["txtIsAdmin"] = "false"; SlideShow slideshow = repository.GetSlideShow(id); ViewData["ValidationMessage"] = String.Empty; ViewData["ImageList"] = new SelectList(BuildImageList(), "Value", "Text", ""); ViewData["MusicList"] = new SelectList(BuildMusicList(), "Value", "Text", ""); ViewData["ImageUrl"] = firstfile; // Get the image guids for the slideshow string guids = String.Empty; ISlideShowImageXrefRepository xrefrep = new EntitySlideShowImageXrefRepository(); IImageRepository imgrep = new EntityImageRepository(); IEnumerable<SlideShowImageXref> xrefs = xrefrep.GetSlideShowImageXrefs(id); foreach (SlideShowImageXref xref in xrefs) { Image img = imgrep.GetImage(xref.ImageID); guids += "|" + img.StoredFilename; } ViewData["SlideShowImages"] = guids; ViewData["SlideShowImageList"] = new SelectList(BuildSlideShowImageList(guids), "Value", "Text", ""); // Get the music guids for the slideshow string musicguids = String.Empty; ISlideShowMusicXrefRepository musicxrefrep = new EntitySlideShowMusicXrefRepository(); IMusicRepository musicrep = new EntityMusicRepository(); IEnumerable<SlideShowMusicXref> musicxrefs = musicxrefrep.GetSlideShowMusicXrefs(id); foreach (SlideShowMusicXref musicxref in musicxrefs) { Music msc = musicrep.GetMusic(musicxref.MusicID); musicguids += "|" + msc.StoredFilename; } ViewData["SlideShowMusic"] = musicguids; ViewData["SlideShowMusicList"] = new SelectList(BuildSlideShowMusicList(musicguids), "Value", "Text", ""); ViewData["TransitionTypeList"] = new SelectList(BuildTransitionTypeList(), "Value", "Text", slideshow.TransitionType); // Get the account id int accountid = 0; if (Session["UserAccountID"] != null) accountid = Convert.ToInt32(Session["UserAccountID"]); ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; return View(slideshow); } catch (Exception ex) { Helpers.SetupApplicationError("SlideShow", "Edit", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }
private List<SelectListItem> BuildSlideShowImageList(string imageguids) { IImageRepository imgrep = new EntityImageRepository(); List<SelectListItem> items = new List<SelectListItem>(); // Get the image from the database string[] guids = imageguids.Split('|'); foreach (string guid in guids) { if (!String.IsNullOrEmpty(guid.Trim())) { Image img = imgrep.GetImageByGuid(guid.Trim()); if (img != null) { SelectListItem item = new SelectListItem(); item.Text = img.ImageName; item.Value = img.StoredFilename; items.Add(item); } } } return items; }
public ActionResult Create(ScreenContent screencontent) { try { if (Session["UserAccountID"] == null) return RedirectToAction("Validate", "Login"); User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) ViewData["txtIsAdmin"] = "true"; else ViewData["txtIsAdmin"] = "false"; if (ModelState.IsValid) { // Set NULLs to Empty Strings screencontent = FillNulls(screencontent); screencontent.AccountID = Convert.ToInt32(Session["UserAccountID"]); screencontent.ScreenContentTypeID = Convert.ToInt32(Request.Form["lstScreenContentTypeList"]); IImageRepository imgrep = new EntityImageRepository(); Image img = imgrep.GetImageByGuid(Request.Form["lstImage"]); if (img != null) screencontent.ThumbnailImageID = img.ImageID; else screencontent.ThumbnailImageID = 0; string validation = ValidateInput(screencontent); if (!String.IsNullOrEmpty(validation)) { ViewData["ValidationMessage"] = validation; ViewData["ImageList"] = new SelectList(BuildThumbnailImageList(Request.Form["lstImage"]), "Value", "Text", Request.Form["lstImage"]); ViewData["ImageUrl"] = selectedfile; ViewData["ScreenContentTypeList"] = new SelectList(BuildScreenContentTypeList(false), "Value", "Text", Request.Form["lstScreenContentTypeList"]); ViewData["ScreenContentImages"] = new SelectList(BuildImageList(0), "Value", "Text", Request.Form["lstScreenContentImages"]); ViewData["ScreenContentSlideShows"] = new SelectList(BuildSlideShowList(0), "Value", "Text", Request.Form["lstScreenContentSlideShows"]); ViewData["ScreenContentVideos"] = new SelectList(BuildVideoList(0), "Value", "Text", Request.Form["lstScreenContentVideos"]); ViewData["ScreenContentPlayLists"] = new SelectList(BuildPlayListList(0), "Value", "Text", Request.Form["lstScreenContentPlayLists"]); ViewData["ScreenContentSurveys"] = new SelectList(BuildSurveyList(0), "Value", "Text", ""); ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; return View(screencontent); } else { int screencontenttypeid = Convert.ToInt32(Request.Form["lstScreenContentTypeList"]); if (screencontenttypeid == 1000000) screencontent.CustomField1 = Request.Form["lstScreenContentImages"]; else if (screencontenttypeid == 1000001) screencontent.CustomField1 = Request.Form["lstScreenContentSlideShows"]; else if (screencontenttypeid == 1000002) screencontent.CustomField1 = Request.Form["lstScreenContentVideos"]; else if (screencontenttypeid == 1000003) screencontent.CustomField1 = Request.Form["lstScreenContentPlayLists"]; else if (screencontenttypeid == 1000007) screencontent.CustomField1 = Request.Form["lstScreenContentSurveys"]; repository.CreateScreenContent(screencontent); CommonMethods.CreateActivityLog((User)Session["User"], "Screen Content", "Add", "Added screen content '" + screencontent.ScreenContentName + "' - ID: " + screencontent.ScreenContentID.ToString()); return RedirectToAction("Index"); } } return View(screencontent); } catch (Exception ex) { Helpers.SetupApplicationError("ScreenContent", "Create POST", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }
public void CreateSampleData(int accountid) { // Initialize the sample data for a new account so there is data available try { // Copy the five images for the sample CopySampleImage(accountid, "6f5e187f-52a2-4799-bdac-2e9199580b98.png"); CopySampleImage(accountid, "60255096-6a72-409e-b905-4d98ee717bb0.jpg"); CopySampleImage(accountid, "612bb76c-e16e-4fe8-87f2-bddc7eb59300.jpg"); CopySampleImage(accountid, "69f99c47-d1b0-4123-b62b-8f18bdc5702f.jpg"); CopySampleImage(accountid, "626c6a35-4523-46aa-9d0a-c2687b581e27.jpg"); // Create the image records IImageRepository imagerep = new EntityImageRepository(); Image img1 = new Image(); img1.AccountID = accountid; img1.ImageName = "Visit Las Vegas Button"; img1.OriginalFilename = "vegasbutton.png"; img1.StoredFilename = "6f5e187f-52a2-4799-bdac-2e9199580b98.png"; img1.Tags = "Las Vegas"; img1.IsActive = true; imagerep.CreateImage(img1); Image img2 = new Image(); img2.AccountID = accountid; img2.ImageName = "Vegas 01"; img2.OriginalFilename = "vegas01.jpg"; img2.StoredFilename = "60255096-6a72-409e-b905-4d98ee717bb0.jpg"; img2.Tags = "Las Vegas"; img2.IsActive = true; imagerep.CreateImage(img2); Image img3 = new Image(); img3.AccountID = accountid; img3.ImageName = "Vegas 02"; img3.OriginalFilename = "vegas02.jpg"; img3.StoredFilename = "612bb76c-e16e-4fe8-87f2-bddc7eb59300.jpg"; img3.Tags = "Las Vegas"; img3.IsActive = true; imagerep.CreateImage(img3); Image img4 = new Image(); img4.AccountID = accountid; img4.ImageName = "Vegas 03"; img4.OriginalFilename = "vegas03.jpg"; img4.StoredFilename = "69f99c47-d1b0-4123-b62b-8f18bdc5702f.jpg"; img4.Tags = "Las Vegas"; img4.IsActive = true; imagerep.CreateImage(img4); Image img5 = new Image(); img5.AccountID = accountid; img5.ImageName = "Vegas 04"; img5.OriginalFilename = "vegas04.jpg"; img5.StoredFilename = "626c6a35-4523-46aa-9d0a-c2687b581e27.jpg"; img5.Tags = "Las Vegas"; img5.IsActive = true; imagerep.CreateImage(img5); // Create a slideshow with the four images ISlideShowRepository slideshowrep = new EntitySlideShowRepository(); ISlideShowImageXrefRepository ssixrefrep = new EntitySlideShowImageXrefRepository(); SlideShow slideshow = new SlideShow(); slideshow.AccountID = accountid; slideshow.SlideShowName = "Visit Vegas Slideshow"; slideshow.Tags = "Las Vegas"; slideshow.TransitionType = "Fade"; slideshow.IntervalInSecs = 10; slideshow.IsActive = true; slideshowrep.CreateSlideShow(slideshow); SlideShowImageXref xref1 = new SlideShowImageXref(); xref1.PlayOrder = 1; xref1.SlideShowID = slideshow.SlideShowID; xref1.ImageID = img2.ImageID; ssixrefrep.CreateSlideShowImageXref(xref1); SlideShowImageXref xref2 = new SlideShowImageXref(); xref2.PlayOrder = 2; xref2.SlideShowID = slideshow.SlideShowID; xref2.ImageID = img3.ImageID; ssixrefrep.CreateSlideShowImageXref(xref2); SlideShowImageXref xref3 = new SlideShowImageXref(); xref3.PlayOrder = 3; xref3.SlideShowID = slideshow.SlideShowID; xref3.ImageID = img4.ImageID; ssixrefrep.CreateSlideShowImageXref(xref3); SlideShowImageXref xref4 = new SlideShowImageXref(); xref4.PlayOrder = 4; xref4.SlideShowID = slideshow.SlideShowID; xref4.ImageID = img5.ImageID; ssixrefrep.CreateSlideShowImageXref(xref4); // Create one screencontent item for each image IScreenContentRepository screencontentrep = new EntityScreenContentRepository(); ScreenContent content1 = new ScreenContent(); content1.AccountID = accountid; content1.ScreenContentName = "Vegas 01 Image"; content1.ScreenContentTitle = "Las Vegas Is Fun!"; content1.ScreenContentTypeID = 1000000; content1.ThumbnailImageID = img2.ImageID; content1.CustomField1 = img2.ImageID.ToString(); content1.CustomField2 = String.Empty; content1.CustomField3 = String.Empty; content1.CustomField4 = String.Empty; content1.IsActive = true; screencontentrep.CreateScreenContent(content1); ScreenContent content2 = new ScreenContent(); content2.AccountID = accountid; content2.ScreenContentName = "Vegas 02 Image"; content2.ScreenContentTitle = "Visit Las Vegas!"; content2.ScreenContentTypeID = 1000000; content2.ThumbnailImageID = img3.ImageID; content2.CustomField1 = img3.ImageID.ToString(); content2.CustomField2 = String.Empty; content2.CustomField3 = String.Empty; content2.CustomField4 = String.Empty; content2.IsActive = true; screencontentrep.CreateScreenContent(content2); ScreenContent content3 = new ScreenContent(); content3.AccountID = accountid; content3.ScreenContentName = "Vegas 03 Image"; content3.ScreenContentTitle = "There's so much to do in Vegas!"; content3.ScreenContentTypeID = 1000000; content3.ThumbnailImageID = img4.ImageID; content3.CustomField1 = img4.ImageID.ToString(); content3.CustomField2 = String.Empty; content3.CustomField3 = String.Empty; content3.CustomField4 = String.Empty; content3.IsActive = true; screencontentrep.CreateScreenContent(content3); ScreenContent content4 = new ScreenContent(); content4.AccountID = accountid; content4.ScreenContentName = "Vegas 04 Image"; content4.ScreenContentTitle = "Good times, day or night!"; content4.ScreenContentTypeID = 1000000; content4.ThumbnailImageID = img5.ImageID; content4.CustomField1 = img5.ImageID.ToString(); content4.CustomField2 = String.Empty; content4.CustomField3 = String.Empty; content4.CustomField4 = String.Empty; content4.IsActive = true; screencontentrep.CreateScreenContent(content4); // Create the screen with slideshow and four screen content items IScreenRepository screenrep = new EntityScreenRepository(); IScreenScreenContentXrefRepository sscxrefrep = new EntityScreenScreenContentXrefRepository(); Screen screen = new Screen(); screen.ButtonImageID = img1.ImageID; screen.AccountID = accountid; screen.IsInteractive = true; screen.PlayListID = 0; screen.SlideShowID = slideshow.SlideShowID; screen.ScreenName = "Visit Las Vegas"; screen.ScreenDescription = String.Empty; screen.IsActive = true; screenrep.CreateScreen(screen); ScreenScreenContentXref sscxref1 = new ScreenScreenContentXref(); sscxref1.ScreenID = screen.ScreenID; sscxref1.ScreenContentID = content1.ScreenContentID; sscxref1.DisplayOrder = 1; sscxrefrep.CreateScreenScreenContentXref(sscxref1); ScreenScreenContentXref sscxref2 = new ScreenScreenContentXref(); sscxref2.ScreenID = screen.ScreenID; sscxref2.ScreenContentID = content2.ScreenContentID; sscxref2.DisplayOrder = 2; sscxrefrep.CreateScreenScreenContentXref(sscxref2); ScreenScreenContentXref sscxref3 = new ScreenScreenContentXref(); sscxref3.ScreenID = screen.ScreenID; sscxref3.ScreenContentID = content3.ScreenContentID; sscxref3.DisplayOrder = 3; sscxrefrep.CreateScreenScreenContentXref(sscxref3); ScreenScreenContentXref sscxref4 = new ScreenScreenContentXref(); sscxref4.ScreenID = screen.ScreenID; sscxref4.ScreenContentID = content4.ScreenContentID; sscxref4.DisplayOrder = 4; sscxrefrep.CreateScreenScreenContentXref(sscxref4); // Create a PlayerGroup - My Players IPlayerGroupRepository playergrouprep = new EntityPlayerGroupRepository(); PlayerGroup playergroup = new PlayerGroup(); playergroup.AccountID = accountid; playergroup.PlayerGroupName = "My Players"; playergroup.PlayerGroupDescription = String.Empty; playergroup.IsActive = true; playergrouprep.CreatePlayerGroup(playergroup); // Create a Player - My Player IPlayerRepository playerrep = new EntityPlayerRepository(); Player player = new Player(); player.AccountID = accountid; player.PlayerGroupID = playergroup.PlayerGroupID; player.PlayerName = "My Player"; player.PlayerLocation = String.Empty; player.PlayerDescription = String.Empty; player.IsActive = true; playerrep.CreatePlayer(player); // Create the schedule for My Players player group IPlayerGroupScheduleRepository schedulerep = new EntityPlayerGroupScheduleRepository(); PlayerGroupSchedule schedule1 = new PlayerGroupSchedule(); schedule1.PlayerGroupID = playergroup.PlayerGroupID; schedule1.ScreenID = screen.ScreenID; schedule1.Day = 0; schedule1.Hour = 0; schedule1.Minute = 0; schedulerep.CreatePlayerGroupSchedule(schedule1); PlayerGroupSchedule schedule2 = new PlayerGroupSchedule(); schedule2.PlayerGroupID = playergroup.PlayerGroupID; schedule2.ScreenID = screen.ScreenID; schedule2.Day = 1; schedule2.Hour = 0; schedule2.Minute = 0; schedulerep.CreatePlayerGroupSchedule(schedule2); PlayerGroupSchedule schedule3 = new PlayerGroupSchedule(); schedule3.PlayerGroupID = playergroup.PlayerGroupID; schedule3.ScreenID = screen.ScreenID; schedule3.Day = 2; schedule3.Hour = 0; schedule3.Minute = 0; schedulerep.CreatePlayerGroupSchedule(schedule3); PlayerGroupSchedule schedule4 = new PlayerGroupSchedule(); schedule4.PlayerGroupID = playergroup.PlayerGroupID; schedule4.ScreenID = screen.ScreenID; schedule4.Day = 3; schedule4.Hour = 0; schedule4.Minute = 0; schedulerep.CreatePlayerGroupSchedule(schedule4); PlayerGroupSchedule schedule5 = new PlayerGroupSchedule(); schedule5.PlayerGroupID = playergroup.PlayerGroupID; schedule5.ScreenID = screen.ScreenID; schedule5.Day = 4; schedule5.Hour = 0; schedule5.Minute = 0; schedulerep.CreatePlayerGroupSchedule(schedule5); PlayerGroupSchedule schedule6 = new PlayerGroupSchedule(); schedule6.PlayerGroupID = playergroup.PlayerGroupID; schedule6.ScreenID = screen.ScreenID; schedule6.Day = 5; schedule6.Hour = 0; schedule6.Minute = 0; schedulerep.CreatePlayerGroupSchedule(schedule6); PlayerGroupSchedule schedule7 = new PlayerGroupSchedule(); schedule7.PlayerGroupID = playergroup.PlayerGroupID; schedule7.ScreenID = screen.ScreenID; schedule7.Day = 6; schedule7.Hour = 0; schedule7.Minute = 0; schedulerep.CreatePlayerGroupSchedule(schedule7); } catch { } }
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; }
// // GET: /ScreenContent/ public ActionResult Index() { try { if (Session["UserAccountID"] == null) return RedirectToAction("Validate", "Login"); User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) ViewData["txtIsAdmin"] = "true"; else ViewData["txtIsAdmin"] = "false"; // Initialize or get the page state using session ScreenContentPageState pagestate = GetPageState(); // Get the account id int accountid = 0; if (Session["UserAccountID"] != null) accountid = Convert.ToInt32(Session["UserAccountID"]); // Set and save the page state to the submitted form values if any values are passed if (Request.Form["lstAscDesc"] != null) { pagestate.AccountID = accountid; pagestate.ScreenContentName = Request.Form["txtScreenContentName"].ToString().Trim(); pagestate.ScreenContentTypeID = Convert.ToInt32(Request.Form["lstScreenContentTypeList"]); if (Request.Form["chkIncludeInactive"].ToLower().StartsWith("true")) pagestate.IncludeInactive = true; else pagestate.IncludeInactive = false; pagestate.SortBy = Request.Form["lstSortBy"].ToString().Trim(); pagestate.AscDesc = Request.Form["lstAscDesc"].ToString().Trim(); pagestate.PageNumber = Convert.ToInt32(Request.Form["txtPageNumber"].ToString().Trim()); SavePageState(pagestate); } // Add the session values to the view data so they can be populated in the form ViewData["AccountID"] = pagestate.AccountID; ViewData["ScreenContentName"] = pagestate.ScreenContentName; ViewData["ScreenContentTypeID"] = pagestate.ScreenContentTypeID; ViewData["IncludeInactive"] = pagestate.IncludeInactive; ViewData["SortBy"] = pagestate.SortBy; ViewData["SortByList"] = new SelectList(BuildSortByList(), "Value", "Text", pagestate.SortBy); ViewData["AscDescList"] = new SelectList(BuildAscDescList(), "Value", "Text", pagestate.AscDesc); ViewData["ScreenContentTypeList"] = new SelectList(BuildScreenContentTypeList(true), "Value", "Text", pagestate.ScreenContentTypeID); // Determine asc/desc bool isdescending = false; if (pagestate.AscDesc.ToLower().StartsWith("d")) isdescending = true; // Get a Count of all filtered records int recordcount = repository.GetScreenContentRecordCount(pagestate.AccountID, pagestate.ScreenContentName, pagestate.ScreenContentTypeID, pagestate.IncludeInactive); // Determine the page count int pagecount = 1; if (recordcount > 0) { pagecount = recordcount / Constants.PageSize; if (recordcount % Constants.PageSize != 0) // Add a page if there are more records { pagecount = pagecount + 1; } } // Make sure the current page is not greater than the page count if (pagestate.PageNumber > pagecount) { pagestate.PageNumber = pagecount; SavePageState(pagestate); } // Set the page number and account in viewdata ViewData["PageNumber"] = Convert.ToString(pagestate.PageNumber); ViewData["PageCount"] = Convert.ToString(pagecount); ViewData["RecordCount"] = Convert.ToString(recordcount); // Set the image folder ViewData["ImageFolder"] = @"~/Media/" + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; // Need to return the stored filename and content type name IEnumerable<ScreenContent> screencontents = repository.GetScreenContentPage(pagestate.AccountID, pagestate.ScreenContentName, pagestate.ScreenContentTypeID, pagestate.IncludeInactive, pagestate.SortBy, isdescending, pagestate.PageNumber, pagecount); IScreenContentTypeRepository sctrep = new EntityScreenContentTypeRepository(); IImageRepository imgrep = new EntityImageRepository(); List<ScreenContentView> contentviews = new List<ScreenContentView>(); foreach (ScreenContent screencontent in screencontents) { ScreenContentView contentview = new ScreenContentView(); contentview.ScreenContentID = screencontent.ScreenContentID; contentview.AccountID = screencontent.AccountID; contentview.ScreenContentTypeID = screencontent.ScreenContentTypeID; ScreenContentType sctype = sctrep.GetScreenContentType(screencontent.ScreenContentTypeID); contentview.ScreenContentTypeName = sctype.ScreenContentTypeName; contentview.ScreenContentName = screencontent.ScreenContentName; contentview.ScreenContentTitle = screencontent.ScreenContentTitle; contentview.ThumbnailImageID = screencontent.ThumbnailImageID; Image img = imgrep.GetImage(screencontent.ThumbnailImageID); contentview.StoredFilename = img.StoredFilename; contentview.CustomField1 = screencontent.CustomField1; contentview.CustomField2 = screencontent.CustomField2; contentview.CustomField3 = screencontent.CustomField3; contentview.CustomField4 = screencontent.CustomField4; contentview.IsActive = screencontent.IsActive; contentviews.Add(contentview); } ViewResult result = View(contentviews); result.ViewName = "Index"; return result; } catch (Exception ex) { Helpers.SetupApplicationError("ScreenContent", "Index", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }
// // GET: /ScreenContent/Edit/5 public ActionResult Edit(int id) { try { if (Session["UserAccountID"] == null) return RedirectToAction("Validate", "Login"); User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) ViewData["txtIsAdmin"] = "true"; else ViewData["txtIsAdmin"] = "false"; ScreenContent screencontent = repository.GetScreenContent(id); ViewData["ValidationMessage"] = String.Empty; IImageRepository imgrep = new EntityImageRepository(); Image img = imgrep.GetImage(screencontent.ThumbnailImageID); ViewData["ImageList"] = new SelectList(BuildThumbnailImageList(img.StoredFilename), "Value", "Text", img.StoredFilename); ViewData["ImageUrl"] = selectedfile; ViewData["ScreenContentTypeList"] = new SelectList(BuildScreenContentTypeList(false), "Value", "Text", screencontent.ScreenContentTypeID); int currentimageid = 0; int currentslideshowid = 0; int currentvideoid = 0; int currentplaylistid = 0; int currentsurveyid = 0; if (screencontent.ScreenContentTypeID == 1000000) currentimageid = Convert.ToInt32(screencontent.CustomField1); else if (screencontent.ScreenContentTypeID == 1000001) currentslideshowid = Convert.ToInt32(screencontent.CustomField1); else if (screencontent.ScreenContentTypeID == 1000002) currentvideoid = Convert.ToInt32(screencontent.CustomField1); else if (screencontent.ScreenContentTypeID == 1000003) currentplaylistid = Convert.ToInt32(screencontent.CustomField1); else if (screencontent.ScreenContentTypeID == 1000007) currentsurveyid = Convert.ToInt32(screencontent.CustomField1); ViewData["ScreenContentImages"] = new SelectList(BuildImageList(currentimageid), "Value", "Text", ""); ViewData["ScreenContentSlideShows"] = new SelectList(BuildSlideShowList(currentslideshowid), "Value", "Text", ""); ViewData["ScreenContentVideos"] = new SelectList(BuildVideoList(currentvideoid), "Value", "Text", ""); ViewData["ScreenContentPlayLists"] = new SelectList(BuildPlayListList(currentplaylistid), "Value", "Text", ""); ViewData["ScreenContentSurveys"] = new SelectList(BuildSurveyList(currentsurveyid), "Value", "Text", ""); ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; return View(screencontent); } catch (Exception ex) { Helpers.SetupApplicationError("ScreenContent", "Edit", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }
public ActionResult Create(Screen screen) { try { if (Session["UserAccountID"] == null) return RedirectToAction("Validate", "Login"); User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) ViewData["txtIsAdmin"] = "true"; else ViewData["txtIsAdmin"] = "false"; if (ModelState.IsValid) { // Set NULLs to Empty Strings screen = FillNulls(screen); screen.AccountID = Convert.ToInt32(Session["UserAccountID"]); screen.SlideShowID = Convert.ToInt32(Request.Form["lstSlideShow"]); screen.PlayListID = Convert.ToInt32(Request.Form["lstPlayList"]); string buttonimageguid = Request.Form["lstButtonImage"]; IImageRepository imgrep = new EntityImageRepository(); Image img = imgrep.GetImageByGuid(buttonimageguid); if (img != null) screen.ButtonImageID = img.ImageID; else screen.ButtonImageID = 0; string validation = ValidateInput(screen); if (!String.IsNullOrEmpty(validation)) { ViewData["ValidationMessage"] = validation; ViewData["ImageList"] = new SelectList(BuildImageList(Request.Form["lstButtonImage"]), "Value", "Text", Request.Form["lstButtonImage"]); ViewData["ImageUrl"] = selectedfile; ViewData["SlideShowList"] = new SelectList(BuildSlideShowList(), "Value", "Text", Request.Form["lstSlideShow"]); ViewData["PlayListList"] = new SelectList(BuildPlayListList(), "Value", "Text", Request.Form["lstPlayList"]); ViewData["ScreenContentList"] = new SelectList(BuildScreenContentList(), "Value", "Text", ""); ViewData["ScreenScreenContentList"] = new SelectList(BuildScreenScreenContentList(screen.ScreenID), "Value", "Text", ""); ViewData["ScreenScreenContent"] = Request.Form["txtScreenScreenContent"]; int accountid = 0; if (Session["UserAccountID"] != null) accountid = Convert.ToInt32(Session["UserAccountID"]); ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; return View(screen); } else { repository.CreateScreen(screen); CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Add", "Added screen '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString()); // Create a xref for each screen content in the screen IScreenScreenContentXrefRepository sscrep = new EntityScreenScreenContentXrefRepository(); string[] ids = Request.Form["txtScreenScreenContent"].ToString().Split('|'); int i = 1; foreach (string id in ids) { if (!String.IsNullOrEmpty(id.Trim())) { ScreenScreenContentXref ssc = new ScreenScreenContentXref(); ssc.DisplayOrder = i; ssc.ScreenID = screen.ScreenID; ssc.ScreenContentID = Convert.ToInt32(id); sscrep.CreateScreenScreenContentXref(ssc); i += 1; } } return RedirectToAction("Index"); } } return View(screen); } catch (Exception ex) { Helpers.SetupApplicationError("Screen", "Create POST", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }
// // GET: /Screen/Edit/5 public ActionResult Edit(int id) { try { if (Session["UserAccountID"] == null) return RedirectToAction("Validate", "Login"); User user = (User)Session["User"]; ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"])); if (user.IsAdmin) ViewData["txtIsAdmin"] = "true"; else ViewData["txtIsAdmin"] = "false"; Screen screen = repository.GetScreen(id); ViewData["ValidationMessage"] = String.Empty; IImageRepository imgrep = new EntityImageRepository(); Image img = imgrep.GetImage(screen.ButtonImageID); ViewData["ImageList"] = new SelectList(BuildImageList(img.StoredFilename), "Value", "Text", img.StoredFilename); ViewData["ImageUrl"] = selectedfile; ViewData["SlideShowList"] = new SelectList(BuildSlideShowList(), "Value", "Text", screen.SlideShowID); ViewData["PlayListList"] = new SelectList(BuildPlayListList(), "Value", "Text", screen.PlayListID); ViewData["ScreenContentList"] = new SelectList(BuildScreenContentList(), "Value", "Text", ""); ViewData["ScreenScreenContentList"] = new SelectList(BuildScreenScreenContentList(screen.ScreenID), "Value", "Text", ""); // Get the content ids for the screen string ids = String.Empty; IScreenScreenContentXrefRepository sscrep = new EntityScreenScreenContentXrefRepository(); IEnumerable<ScreenScreenContentXref> sscs = sscrep.GetScreenScreenContentXrefs(screen.ScreenID); foreach (ScreenScreenContentXref ssc in sscs) { ids += "|" + ssc.ScreenContentID.ToString(); } ViewData["ScreenScreenContent"] = ids; int accountid = 0; if (Session["UserAccountID"] != null) accountid = Convert.ToInt32(Session["UserAccountID"]); ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; return View(screen); } catch (Exception ex) { Helpers.SetupApplicationError("Screen", "Edit", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }