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(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"]); 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")); } }
public ActionResult Step1(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 validation = ValidateInput(screen); if (!String.IsNullOrEmpty(validation)) { ViewData["ValidationMessage"] = validation; ViewData["MainFeatureTypeList"] = new SelectList(BuildMainFeatureTypeList(), "Value", "Text", Request.Form["lstMainFeatureType"]); return(View(screen)); } else { string mainfeaturetype = Request.Form["lstMainFeatureType"]; if (mainfeaturetype == "Slide Show") { if (screen.SlideShowID <= 0) { screen.SlideShowID = -1; } screen.PlayListID = 0; screen.TimelineID = 0; } else if (mainfeaturetype == "Play List") { screen.SlideShowID = 0; if (screen.PlayListID <= 0) { screen.PlayListID = -1; } screen.TimelineID = 0; } else if (mainfeaturetype == "Media Timeline") { screen.SlideShowID = 0; screen.PlayListID = 0; if (screen.TimelineID <= 0) { screen.TimelineID = -1; } } if (screen.ScreenID == 0) { repository.CreateScreen(screen); } else { repository.UpdateScreen(screen); } CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Wizard Step 1", "Step 1 '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString()); return(RedirectToAction("Step2", new { id = screen.ScreenID })); } } return(View(screen)); } catch (Exception ex) { Helpers.SetupApplicationError("ScreenWizard", "Step 1 POST", ex.Message); return(RedirectToAction("Index", "ApplicationError")); } }