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 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"); } }
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(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"); } }