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(Convert.ToInt32(Session["UserAccountID"]), guid.Trim()); if (img != null) { SelectListItem item = new SelectListItem(); item.Text = img.ImageName; item.Value = img.StoredFilename; items.Add(item); } } } return(items); }
private List <SelectListItem> BuildTimelineMediaList(string mediaguids) { IImageRepository imgrep = new EntityImageRepository(); IVideoRepository vidrep = new EntityVideoRepository(); List <SelectListItem> items = new List <SelectListItem>(); // Get the images and videos from the database string[] guids = mediaguids.Split('|'); foreach (string guid in guids) { if (!String.IsNullOrEmpty(guid.Trim())) { Image img = imgrep.GetImageByGuid(Convert.ToInt32(Session["UserAccountID"]), guid.Trim()); if (img != null) { SelectListItem item = new SelectListItem(); item.Text = img.ImageName + " (Image)"; item.Value = img.StoredFilename; items.Add(item); } else { Video vid = vidrep.GetVideoByGuid(Convert.ToInt32(Session["UserAccountID"]), guid.Trim()); if (vid != null) { SelectListItem item = new SelectListItem(); item.Text = vid.VideoName + " (Video)"; item.Value = vid.StoredFilename; items.Add(item); } } } } return(items); }
public ActionResult Edit(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.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(Convert.ToInt32(Session["UserAccountID"]), 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"]); 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 { // Update the screen repository.UpdateScreen(screen); CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Edit", "Edited screen '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString()); IScreenScreenContentXrefRepository xrefrep = new EntityScreenScreenContentXrefRepository(); // Delete existing xrefs for the screen xrefrep.DeleteScreenScreenContentXrefs(screen.ScreenID); // 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", "Edit POST", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }
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(Convert.ToInt32(Session["UserAccountID"]), 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 Edit(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.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(Convert.ToInt32(Session["UserAccountID"]), 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"]); 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 { // Update the screen repository.UpdateScreen(screen); CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Edit", "Edited screen '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString()); IScreenScreenContentXrefRepository xrefrep = new EntityScreenScreenContentXrefRepository(); // Delete existing xrefs for the screen xrefrep.DeleteScreenScreenContentXrefs(screen.ScreenID); // 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", "Edit POST", ex.Message); return(RedirectToAction("Index", "ApplicationError")); } }
public ActionResult Edit(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); string validation = ValidateInput(slideshow, Request.Form["txtSlideShowImages"].ToString()); if (!String.IsNullOrEmpty(validation)) { ViewData["ValidationMessage"] = validation; ViewData["ImageList"] = new SelectList(BuildImageList(), "Value", "Text", ""); ViewData["ImageUrl"] = firstfile; ViewData["SlideShowImages"] = Request.Form["txtSlideShowImages"].ToString(); ViewData["SlideShowMusic"] = 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", 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)); } else { // Update the slideshow slideshow.TransitionType = Request.Form["lstTransitionType"].ToString(); repository.UpdateSlideShow(slideshow); CommonMethods.CreateActivityLog((User)Session["User"], "Slide Show", "Edit", "Edited slide show '" + slideshow.SlideShowName + "' - ID: " + slideshow.SlideShowID.ToString()); ISlideShowImageXrefRepository xrefrep = new EntitySlideShowImageXrefRepository(); ISlideShowMusicXrefRepository musicxrefrep = new EntitySlideShowMusicXrefRepository(); IImageRepository imgrep = new EntityImageRepository(); IMusicRepository musicrep = new EntityMusicRepository(); // Delete existing xrefs for the slideshow xrefrep.DeleteSlideShowImageXrefs(slideshow.SlideShowID); musicxrefrep.DeleteSlideShowMusicXrefs(slideshow.SlideShowID); // 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(Convert.ToInt32(Session["UserAccountID"]), 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(Convert.ToInt32(Session["UserAccountID"]), 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", "Edit POST", ex.Message); return(RedirectToAction("Index", "ApplicationError")); } }
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(Convert.ToInt32(Session["UserAccountID"]), 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")); } }
private Image CreateExampleImage(int accountid, string imagename, string originalfilename, string storedfilename, string tags) { try { string sourceimage = HttpContext.Current.Server.MapPath(@"~/ExampleImages/" + storedfilename); string newimage = HttpContext.Current.Server.MapPath(@"~/Media"); if (!newimage.EndsWith(@"\")) newimage += @"\"; System.IO.Directory.CreateDirectory(newimage + Convert.ToString(accountid) + @"\Images\"); newimage += Convert.ToString(accountid) + @"\Images\" + storedfilename; if (!System.IO.File.Exists(newimage)) System.IO.File.Copy(sourceimage, newimage); IImageRepository imagerep = new EntityImageRepository(); Image image = imagerep.GetImageByGuid(accountid, storedfilename); if (image == null || image.ImageID == 0) { image = new Image(); image.AccountID = accountid; image.ImageName = imagename; image.OriginalFilename = originalfilename; image.StoredFilename = storedfilename; image.Tags = tags; image.IsActive = true; imagerep.CreateImage(image); } return image; } catch { return null; } }
public ActionResult Step3(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"]); string buttonimageguid = Request.Form["lstButtonImage"]; IImageRepository imgrep = new EntityImageRepository(); Image img = imgrep.GetImageByGuid(Convert.ToInt32(Session["UserAccountID"]), buttonimageguid); if (img != null) { screen.ButtonImageID = img.ImageID; } else { screen.ButtonImageID = 0; } string validation = ValidateInput(screen); if (!String.IsNullOrEmpty(validation)) { ViewData["ValidationMessage"] = validation; ViewData["ScreenID"] = screen.ScreenID; if (img == null) { ViewData["ImageList"] = new SelectList(BuildImageList(""), "Value", "Text", ""); } else { ViewData["ImageList"] = new SelectList(BuildImageList(img.StoredFilename), "Value", "Text", img.StoredFilename); } if (!String.IsNullOrEmpty(selectedfile)) { ViewData["ImageUrl"] = selectedfile; } else { ViewData["ImageUrl"] = firstfile; } 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.UpdateScreen(screen); CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Wizard Step 3", "Step 3 '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString()); if (screen.IsInteractive) { return(RedirectToAction("Step4", new { id = screen.ScreenID })); } else { return(RedirectToAction("Index", "Screen")); } } } return(View(screen)); } catch (Exception ex) { Helpers.SetupApplicationError("ScreenWizard", "Step 3 POST", ex.Message); return(RedirectToAction("Index", "ApplicationError")); } }
public ActionResult Edit(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(Convert.ToInt32(Session["UserAccountID"]), 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["ScreenContentTimelines"] = new SelectList(BuildTimelineList(0), "Value", "Text", Request.Form["lstScreenContentTimelines"]); 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"]; } else if (screencontenttypeid == 1000008) { screencontent.CustomField1 = Request.Form["lstScreenContentTimelines"]; } repository.UpdateScreenContent(screencontent); CommonMethods.CreateActivityLog((User)Session["User"], "Screen Content", "Edit", "Edited screen content '" + screencontent.ScreenContentName + "' - ID: " + screencontent.ScreenContentID.ToString()); return(RedirectToAction("Index")); } } return(View(screencontent)); } catch (Exception ex) { Helpers.SetupApplicationError("ScreenContent", "Edit POST", ex.Message); return(RedirectToAction("Index", "ApplicationError")); } }
public ActionResult Step3(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"]); string buttonimageguid = Request.Form["lstButtonImage"]; IImageRepository imgrep = new EntityImageRepository(); Image img = imgrep.GetImageByGuid(Convert.ToInt32(Session["UserAccountID"]), buttonimageguid); if (img != null) screen.ButtonImageID = img.ImageID; else screen.ButtonImageID = 0; string validation = ValidateInput(screen); if (!String.IsNullOrEmpty(validation)) { ViewData["ValidationMessage"] = validation; ViewData["ScreenID"] = screen.ScreenID; if (img == null) ViewData["ImageList"] = new SelectList(BuildImageList(""), "Value", "Text", ""); else ViewData["ImageList"] = new SelectList(BuildImageList(img.StoredFilename), "Value", "Text", img.StoredFilename); if (!String.IsNullOrEmpty(selectedfile)) ViewData["ImageUrl"] = selectedfile; else ViewData["ImageUrl"] = firstfile; 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.UpdateScreen(screen); CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Wizard Step 3", "Step 3 '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString()); if (screen.IsInteractive) return RedirectToAction("Step4", new { id = screen.ScreenID }); else return RedirectToAction("Index", "Screen"); } } return View(screen); } catch (Exception ex) { Helpers.SetupApplicationError("ScreenWizard", "Step 3 POST", ex.Message); return RedirectToAction("Index", "ApplicationError"); } }
public ActionResult Edit(Timeline timeline) { 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 timeline = FillNulls(timeline); timeline.AccountID = Convert.ToInt32(Session["UserAccountID"]); string validation = ValidateInput(timeline); if (!String.IsNullOrEmpty(validation)) { ViewData["ValidationMessage"] = validation; ViewData["ImageList"] = new SelectList(BuildImageList(), "Value", "Text", ""); ViewData["MusicList"] = new SelectList(BuildMusicList(), "Value", "Text", ""); ViewData["VideoList"] = new SelectList(BuildVideoList(), "Value", "Text", ""); ViewData["TimelineMediaList"] = new SelectList(BuildTimelineMediaList(Request.Form["txtTimelineMedia"].ToString()), "Value", "Text", ""); ViewData["TimelineMusicList"] = new SelectList(BuildTimelineMusicList(Request.Form["txtTimelineMusic"].ToString()), "Value", "Text", ""); ViewData["TimelineMedia"] = Request.Form["txtTimelineMedia"].ToString();; ViewData["TimelineMusic"] = Request.Form["txtTimelineMusic"].ToString();; ViewData["ImageUrl"] = firstimagefile; ViewData["ImageFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Images/"; ViewData["VideoUrl"] = firstvideofile; ViewData["VideoFolder"] = ConfigurationManager.AppSettings["MediaRootFolder"] + Convert.ToString(Session["UserAccountID"]) + @"/Videos/"; return(View(timeline)); } else { // Update the timeline repository.UpdateTimeline(timeline); CommonMethods.CreateActivityLog((User)Session["User"], "Timeline", "Edit", "Edited timeline '" + timeline.TimelineName + "' - ID: " + timeline.TimelineID.ToString()); string[] guids; int i = 0; // Delete the image, video, and music xrefs, then create new ones ITimelineImageXrefRepository imagexrefrep = new EntityTimelineImageXrefRepository(); ITimelineVideoXrefRepository videoxrefrep = new EntityTimelineVideoXrefRepository(); ITimelineMusicXrefRepository musicxrefrep = new EntityTimelineMusicXrefRepository(); imagexrefrep.DeleteTimelineImageXrefs(timeline.TimelineID); videoxrefrep.DeleteTimelineVideoXrefs(timeline.TimelineID); musicxrefrep.DeleteTimelineMusicXrefs(timeline.TimelineID); // Create the image xrefs IImageRepository imagerep = new EntityImageRepository(); guids = Request.Form["txtTimelineMedia"].ToString().Split('|'); i = 1; foreach (string guid in guids) { if (!String.IsNullOrEmpty(guid.Trim())) { Image image = imagerep.GetImageByGuid(Convert.ToInt32(Session["UserAccountID"]), guid); if (image != null) { TimelineImageXref xref = new TimelineImageXref(); xref.DisplayOrder = i; xref.TimelineID = timeline.TimelineID; xref.ImageID = image.ImageID; imagexrefrep.CreateTimelineImageXref(xref); } i += 1; } } // Create the video xrefs IVideoRepository videorep = new EntityVideoRepository(); guids = Request.Form["txtTimelineMedia"].ToString().Split('|'); i = 1; foreach (string guid in guids) { if (!String.IsNullOrEmpty(guid.Trim())) { Video video = videorep.GetVideoByGuid(Convert.ToInt32(Session["UserAccountID"]), guid); if (video != null) { TimelineVideoXref xref = new TimelineVideoXref(); xref.DisplayOrder = i; xref.TimelineID = timeline.TimelineID; xref.VideoID = video.VideoID; videoxrefrep.CreateTimelineVideoXref(xref); } i += 1; } } // Create the music xrefs IMusicRepository musicrep = new EntityMusicRepository(); guids = Request.Form["txtTimelineMusic"].ToString().Split('|'); i = 1; foreach (string guid in guids) { if (!String.IsNullOrEmpty(guid.Trim())) { Music music = musicrep.GetMusicByGuid(Convert.ToInt32(Session["UserAccountID"]), guid); if (music != null) { TimelineMusicXref xref = new TimelineMusicXref(); xref.PlayOrder = i; xref.TimelineID = timeline.TimelineID; xref.MusicID = music.MusicID; musicxrefrep.CreateTimelineMusicXref(xref); i += 1; } } } return(RedirectToAction("Index")); } } return(View(timeline)); } catch (Exception ex) { Helpers.SetupApplicationError("Timeline", "Edit POST", ex.Message); return(RedirectToAction("Index", "ApplicationError")); } }