Exemplo n.º 1
0
        private Screen CreateExampleScreen(int accountid, int buttonimageid, int playlistid, int slideshowid, int timelineid, string screenname, List <ScreenContent> screencontents)
        {
            try
            {
                IScreenRepository screenrep = new EntityScreenRepository();
                IScreenScreenContentXrefRepository sscxrefrep = new EntityScreenScreenContentXrefRepository();

                Screen screen = new Screen();
                screen.ButtonImageID     = buttonimageid;
                screen.AccountID         = accountid;
                screen.IsInteractive     = true;
                screen.PlayListID        = playlistid;
                screen.SlideShowID       = slideshowid;
                screen.TimelineID        = timelineid;
                screen.ScreenName        = screenname;
                screen.ScreenDescription = String.Empty;
                screen.IsActive          = true;
                screenrep.CreateScreen(screen);

                int i = 1;
                foreach (ScreenContent screencontent in screencontents)
                {
                    ScreenScreenContentXref sscxref = new ScreenScreenContentXref();
                    sscxref.ScreenID        = screen.ScreenID;
                    sscxref.ScreenContentID = screencontent.ScreenContentID;
                    sscxref.DisplayOrder    = i;
                    sscxrefrep.CreateScreenScreenContentXref(sscxref);
                    i += 1;
                }

                return(screen);
            }
            catch { return(null); }
        }
Exemplo n.º 2
0
        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 void CreateScreenScreenContentXref(ScreenScreenContentXref xref)
 {
     db.ScreenScreenContentXrefs.Add(xref);
     db.SaveChanges();
 }
Exemplo n.º 4
0
        private Screen CreateExampleScreen(int accountid, int buttonimageid, int playlistid, int slideshowid, int timelineid, string screenname, List<ScreenContent> screencontents)
        {
            try
            {
                IScreenRepository screenrep = new EntityScreenRepository();
                IScreenScreenContentXrefRepository sscxrefrep = new EntityScreenScreenContentXrefRepository();

                Screen screen = new Screen();
                screen.ButtonImageID = buttonimageid;
                screen.AccountID = accountid;
                screen.IsInteractive = true;
                screen.PlayListID = playlistid;
                screen.SlideShowID = slideshowid;
                screen.TimelineID = timelineid;
                screen.ScreenName = screenname;
                screen.ScreenDescription = String.Empty;
                screen.IsActive = true;
                screenrep.CreateScreen(screen);

                int i = 1;
                foreach (ScreenContent screencontent in screencontents)
                {
                    ScreenScreenContentXref sscxref = new ScreenScreenContentXref();
                    sscxref.ScreenID = screen.ScreenID;
                    sscxref.ScreenContentID = screencontent.ScreenContentID;
                    sscxref.DisplayOrder = i;
                    sscxrefrep.CreateScreenScreenContentXref(sscxref);
                    i += 1;
                }

                return screen;
            }
            catch { return null; }
        }
Exemplo n.º 5
0
        public ActionResult Step4(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"]);

                    if (String.IsNullOrEmpty(Request.Form["txtScreenScreenContent"]))
                    {
                        ViewData["ScreenScreenContent"] = String.Empty;
                        ViewData["ScreenContentList"] = new SelectList(BuildScreenContentList(), "Value", "Text", "");
                        ViewData["ScreenScreenContentList"] = new SelectList(BuildScreenScreenContentList(screen.ScreenID), "Value", "Text", "");
                        ViewData["ScreenID"] = screen.ScreenID;
                        ViewData["ValidationMessage"] = "Please select one or more screen content items";
                        return View(screen);
                    }
                    else
                    {
                        // Delete and recreate the screen/screen content xrefs
                        IScreenScreenContentXrefRepository xrefrep = new EntityScreenScreenContentXrefRepository();
                        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;
                            }
                        }

                        CommonMethods.CreateActivityLog((User)Session["User"], "Screen", "Wizard Step 4",
                            "Step 4 '" + screen.ScreenName + "' - ID: " + screen.ScreenID.ToString());

                        return RedirectToAction("Index", "Screen");
                    }
                }

                return View(screen);
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("ScreenWizard", "Step 3 POST", ex.Message);
                return RedirectToAction("Index", "ApplicationError");
            }
        }