Ejemplo n.º 1
0
        public ActionResult EditFromID(int websiteID)
        {
            IDBConnector     db      = DBConnectorFactory.GetDBConnector();
            UserWebsiteModel website = db.SelectWebsite(websiteID);

            return(RedirectToAction("Edit", website));
        }
Ejemplo n.º 2
0
        public ActionResult SelectSections(List <SectionModel> sections)
        {
            if (ModelState.IsValid)
            {
                List <DBSectionModel> removePositions = new List <DBSectionModel>();
                List <DBSectionModel> addPositions    = new List <DBSectionModel>();
                foreach (SectionModel section in sections)
                {
                    if (section.IsSelected)
                    {
                        addPositions.Add(ConvertSectionModel(section));
                    }
                    else
                    {
                        removePositions.Add(ConvertSectionModel(section));
                    }
                }

                IDBConnector db = DBConnectorFactory.GetDBConnector();
                db.InsertPositions(addPositions);
                db.DeletePositions(removePositions);

                return(RedirectToAction(StringKeys.EDIT_FROM_ID, StringKeys.PAGE_CONTROLLER, new { pageID = sections[0].PageID }));
            }

            return(View(sections));
        }
Ejemplo n.º 3
0
        public ActionResult EditFromID(int pageID)
        {
            IDBConnector db   = DBConnectorFactory.GetDBConnector();
            DBPageModel  page = db.SelectPage(pageID);

            return(RedirectToAction("Edit", page));
        }
Ejemplo n.º 4
0
        public ActionResult Remove(int sectionID, int pageID)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.DeleteSectionFromPage(sectionID, pageID);

            return(RedirectToAction(StringKeys.EDIT_FROM_ID, StringKeys.PAGE_CONTROLLER, new { pageID }));
        }
Ejemplo n.º 5
0
        public ActionResult Delete(SectionModel section)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.DeleteSection(section.SectionID);

            return(RedirectToAction(StringKeys.EDIT_FROM_ID, StringKeys.PAGE_CONTROLLER, new { pageID = section.PageID }));
        }
Ejemplo n.º 6
0
        public ActionResult Create(DBPageModel page)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.InsertPage(page);

            return(RedirectToAction("EditFromID", "Website", new { websiteID = page.WebsiteID }));
        }
Ejemplo n.º 7
0
        public ActionResult Delete(int UserSocialMediaID)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.DeleteSocialMedia(UserSocialMediaID);

            return(RedirectToAction("Edit", "Profile"));
        }
Ejemplo n.º 8
0
        public ActionResult Delete(int PageID, int WebsiteID)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.DeletePage(PageID);

            return(RedirectToAction("EditFromID", "Website", new { websiteID = WebsiteID }));
        }
Ejemplo n.º 9
0
        public ActionResult Delete(int websiteID)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.DeleteWebsite(websiteID);

            return(RedirectToAction("MyWebsites"));
        }
        public ActionResult Delete(PermissionModel permission)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.DeletePermission(permission.PermissionID);

            return(RedirectToAction("EditFromID", "Website", new { websiteID = permission.WebsiteID }));
        }
Ejemplo n.º 11
0
        public ActionResult Edit(SocialMediaModel model)
        {
            model.LoginID = User.Identity.GetUserId();
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.UpdateSocialMedia(model);

            return(RedirectToAction("Edit", "Profile"));
        }
Ejemplo n.º 12
0
        public ActionResult Edit(int id)
        {
            IDBConnector     db    = DBConnectorFactory.GetDBConnector();
            SocialMediaModel model = db.SelectSocialMedia(id);

            ViewBag.SocialMediaOptions = DropDownGenerator.GetSocialMediaDropDown(model.SocialMediaID);

            return(View(model));
        }
Ejemplo n.º 13
0
        public ActionResult Create(NewWebsiteModel website)
        {
            website.LoginID = User.Identity.GetUserId();
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.InsertWebsite(website);

            return(RedirectToAction("MyWebsites"));
        }
Ejemplo n.º 14
0
        public ActionResult MyWebsites()
        {
            string userID = User.Identity.GetUserId();
            List <UserWebsiteModel> websites = new List <UserWebsiteModel>();

            if (userID != null)
            {
                IDBConnector db = DBConnectorFactory.GetDBConnector();
                websites = db.SelectUserWebsites(userID);
            }

            return(View(websites));
        }
Ejemplo n.º 15
0
        public ActionResult Delete(int pageID, int sectionID)
        {
            IDBConnector   db      = DBConnectorFactory.GetDBConnector();
            DBSectionModel section = db.SelectSection(sectionID);

            if (section != null)
            {
                section.PageID = pageID;

                return(View(ConvertSectionModel(section)));
            }

            return(RedirectToAction(StringKeys.EDIT_FROM_ID, StringKeys.PAGE_CONTROLLER, new { pageID }));
        }
Ejemplo n.º 16
0
        public ActionResult Edit(PageModel page)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.UpdatePage(new DBPageModel()
            {
                PageID = page.PageID, Title = page.Title, DisplayTitle = page.DisplayTitle
            });
            db.UpdateWebsiteHomePage(page.WebsiteID, page.PageID, page.HomePage);

            page.Sections = db.SelectEditPageSections(page.PageID);

            return(View(page));
        }
Ejemplo n.º 17
0
        public ActionResult Create(SectionModel section)
        {
            if (GetValid(section))
            {
                IDBConnector db    = DBConnectorFactory.GetDBConnector();
                int          index = db.InsertSection(ConvertSectionModel(section));

                List <SectionLinkModel> links = MarkdownConverter.FindInternalLinks(section.Text, index);
                db.InsertSectionLinks(links);

                return(RedirectToAction(StringKeys.EDIT_FROM_ID, StringKeys.PAGE_CONTROLLER, new { pageID = section.PageID }));
            }

            return(View(section));
        }
Ejemplo n.º 18
0
        public ActionResult Display(int websiteID, int pageID, int sectionID)
        {
            IDBConnector   db      = DBConnectorFactory.GetDBConnector();
            DBSectionModel section = db.SelectSection(sectionID);

            if (section != null)
            {
                section.PageID = pageID;
                section.Text   = MarkdownConverter.MarkdownToHTML(section.Text, websiteID);

                return(View(ConvertSectionModel(section)));
            }

            return(RedirectToAction(StringKeys.EDIT_FROM_ID, StringKeys.PAGE_CONTROLLER, new { pageID }));
        }
Ejemplo n.º 19
0
        public ActionResult SelectSections(int pageID)
        {
            IDBConnector          db         = DBConnectorFactory.GetDBConnector();
            List <DBSectionModel> dbSections = db.SelectPagePositions(pageID);

            List <SectionModel> sections = new List <SectionModel>();

            foreach (DBSectionModel section in dbSections)
            {
                section.PageID = pageID;
                sections.Add(ConvertSectionModel(section));
            }

            return(View(dbSections));
        }
Ejemplo n.º 20
0
        public ActionResult Delete(TagModel tag)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            if (tag.WebsiteID == -1)
            {
                tag.LoginID = User.Identity.GetUserId();
                db.DeleteUserTag(tag);
            }
            else
            {
                db.DeleteWebsiteTag(tag);
            }

            return(Return(tag));
        }
Ejemplo n.º 21
0
        public ActionResult Edit(UserViewModel user)
        {
            UserModel dbUser = new UserModel()
            {
                LoginID     = User.Identity.GetUserId(),
                UserName    = user.UserName,
                Description = user.Description
            };

            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.UpdateUser(dbUser);
            user.Tags = db.SelectUserTags(dbUser.LoginID);
            user.SocialMediaAccounts = db.SelectUserSocialMedia(dbUser.LoginID);

            return(View(user));
        }
Ejemplo n.º 22
0
        public ActionResult Edit(SectionModel section)
        {
            if (GetValid(section))
            {
                IDBConnector   db        = DBConnectorFactory.GetDBConnector();
                DBSectionModel dbSection = ConvertSectionModel(section);
                db.UpdateSection(dbSection);
                db.UpdatePosition(dbSection);

                List <SectionLinkModel> links = MarkdownConverter.FindInternalLinks(section.Text, section.SectionID);
                db.MergeSectionLinks(links, section.SectionID);

                return(RedirectToAction(StringKeys.EDIT_FROM_ID, StringKeys.PAGE_CONTROLLER, new { pageID = section.PageID }));
            }

            return(View(section));
        }
Ejemplo n.º 23
0
        private UserViewModel PopulateUserModel()
        {
            string       loginID = User.Identity.GetUserId();
            IDBConnector db      = DBConnectorFactory.GetDBConnector();
            UserModel    user    = db.SelectUser(loginID);

            UserViewModel userView = new UserViewModel()
            {
                UserName    = user.UserName,
                Description = user.Description
            };

            userView.Tags = db.SelectUserTags(loginID);
            userView.SocialMediaAccounts = db.SelectUserSocialMedia(loginID);

            return(userView);
        }
Ejemplo n.º 24
0
        private PageModel PopulatePageModel(DBPageModel webpage)
        {
            PageModel page = new PageModel()
            {
                PageID       = webpage.PageID,
                WebsiteID    = webpage.WebsiteID,
                Title        = webpage.Title,
                HomePage     = webpage.HomePage,
                DisplayTitle = webpage.DisplayTitle
            };

            IDBConnector db = DBConnectorFactory.GetDBConnector();

            page.Sections = db.SelectEditPageSections(webpage.PageID);

            return(page);
        }
Ejemplo n.º 25
0
        public ActionResult Edit(WebsiteModel website)
        {
            UserWebsiteModel updateWebsite = new UserWebsiteModel()
            {
                WebsiteID    = website.WebsiteID,
                Title        = website.Title,
                VisibilityID = website.VisibilityID,
                Description  = website.Description
            };

            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.UpdateWebsite(updateWebsite);

            ViewBag.VisibilityOptions = DropDownGenerator.GetVisibilityDropDown(website.VisibilityID - 1);

            return(View(PopulateWebsiteModel(updateWebsite)));
        }
Ejemplo n.º 26
0
        private WebsiteModel PopulateWebsiteModel(UserWebsiteModel website)
        {
            WebsiteModel details = new WebsiteModel()
            {
                WebsiteID    = website.WebsiteID,
                Title        = website.Title,
                VisibilityID = website.VisibilityID,
                Description  = website.Description
            };

            IDBConnector db = DBConnectorFactory.GetDBConnector();

            details.Tags        = db.SelectWebsiteTags(website.WebsiteID);
            details.Pages       = db.SelectWebsitePages(website.WebsiteID);
            details.Permissions = db.SelectWebsitePermissions(website.WebsiteID);

            return(details);
        }
Ejemplo n.º 27
0
        public static List <SelectListItem> GetSocialMediaDropDown(int selected)
        {
            IDBConnector            db     = DBConnectorFactory.GetDBConnector();
            List <SocialMediaModel> models = db.SelectSocialMediaOptions();

            List <SelectListItem> listItems = new List <SelectListItem>();

            foreach (SocialMediaModel model in models)
            {
                listItems.Add(new SelectListItem
                {
                    Text     = model.Name,
                    Value    = model.SocialMediaID.ToString(),
                    Selected = (model.SocialMediaID == selected)
                });
            }

            return(listItems);
        }
Ejemplo n.º 28
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    int    atSign   = user.UserName.IndexOf('@');
                    string userName = user.UserName;
                    if (atSign != -1)
                    {
                        userName = user.UserName.Substring(0, atSign);
                    }

                    IDBConnector db = DBConnectorFactory.GetDBConnector();
                    db.InsertUser(new UserModel()
                    {
                        LoginID = user.Id, UserName = userName
                    });

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 29
0
        // GET: Page
        public ActionResult Display(int pageID)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            DBPageModel dbPage = db.SelectPage(pageID);
            PageModel   page   = new PageModel()
            {
                Title        = dbPage.Title,
                DisplayTitle = dbPage.DisplayTitle,
                PageID       = dbPage.PageID,
                WebsiteID    = dbPage.WebsiteID
            };

            page.Sections = db.SelectViewPageSections(pageID);

            foreach (DBSectionModel section in page.Sections)
            {
                section.Text = MarkdownConverter.MarkdownToHTML(section.Text, dbPage.WebsiteID);
            }

            return(View("Display", "_WebsiteLayout", page));
        }
Ejemplo n.º 30
0
        protected override void ProcessHyperlink(string hyperlink, char hyperlinkType)
        {
            Markdown = Markdown.Remove(Brackets[1], Index - Brackets[1] + 1);
            bool maliciousCodeDetected = (hyperlink.Contains("javascript:") || hyperlink.Contains("\"") || hyperlink.Contains("&"));

            if (hyperlinkType == '?')
            {
                // Make sure the parenthesis only contain a number, the ID of the page to link to
                int  pageID;
                bool success       = int.TryParse(hyperlink, out pageID);
                bool pageInWebsite = false;

                if (success)
                {
                    // Check if the page belongs to this website
                    IDBConnector db = DBConnectorFactory.GetDBConnector();
                    pageInWebsite = db.CheckPageExistence(pageID, this.websiteID);
                }

                if (success && pageInWebsite)
                {
                    // Create an action that opens the linked page
                    Markdown = Markdown.Insert(Brackets[1], "</a>");
                    Markdown = Markdown.Remove(Brackets[0] - 1, 2);
                    Markdown = Markdown.Insert(Brackets[0] - 1, "<a href=\"javascript:openPage(" + pageID + ")\">");
                }
                else
                {
                    // Remove all traces of the link's markdown
                    Markdown = Markdown.Remove(Brackets[0] - 1, 2);
                }
            }
            else if (hyperlinkType == '!')
            {
                if (maliciousCodeDetected)
                {
                    // Remove all traces of the image's markdown
                    Markdown = Markdown.Remove(Brackets[0] - 1, 2);
                }
                else
                {
                    string altText = Markdown.Substring(Brackets[0] + 1, Brackets[1] - (Brackets[0] + 1));
                    Markdown = Markdown.Remove(Brackets[0] - 1, Brackets[1] - Brackets[0] + 1);
                    Markdown = Markdown.Insert(Brackets[0] - 1, "<img src=\"" + hyperlink + "\" alt\"" + altText + "\" class=\"img-responsive\">");
                }
            }
            else
            {
                if (maliciousCodeDetected)
                {
                    // Remove all traces of the link's markdown
                    Markdown = Markdown.Remove(Brackets[0], 1);
                }
                else
                {
                    Markdown = Markdown.Insert(Brackets[1], "</a>");
                    Markdown = Markdown.Remove(Brackets[0], 1);
                    Markdown = Markdown.Insert(Brackets[0], "<a href=\"" + hyperlink + "\" target=\"_blank\" rel=\"noopener\">");
                }
            }
        }