Пример #1
0
        public ActionResult EditFromID(int websiteID)
        {
            IDBConnector     db      = DBConnectorFactory.GetDBConnector();
            UserWebsiteModel website = db.SelectWebsite(websiteID);

            return(RedirectToAction("Edit", website));
        }
Пример #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));
        }
Пример #3
0
        public ActionResult EditFromID(int pageID)
        {
            IDBConnector db   = DBConnectorFactory.GetDBConnector();
            DBPageModel  page = db.SelectPage(pageID);

            return(RedirectToAction("Edit", page));
        }
Пример #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 }));
        }
Пример #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 }));
        }
Пример #6
0
        public ActionResult Create(DBPageModel page)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.InsertPage(page);

            return(RedirectToAction("EditFromID", "Website", new { websiteID = page.WebsiteID }));
        }
Пример #7
0
        public ActionResult Delete(int UserSocialMediaID)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.DeleteSocialMedia(UserSocialMediaID);

            return(RedirectToAction("Edit", "Profile"));
        }
Пример #8
0
        public ActionResult Delete(int PageID, int WebsiteID)
        {
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.DeletePage(PageID);

            return(RedirectToAction("EditFromID", "Website", new { websiteID = WebsiteID }));
        }
Пример #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 }));
        }
Пример #11
0
        public ActionResult Edit(SocialMediaModel model)
        {
            model.LoginID = User.Identity.GetUserId();
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.UpdateSocialMedia(model);

            return(RedirectToAction("Edit", "Profile"));
        }
Пример #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));
        }
Пример #13
0
        public ActionResult Create(NewWebsiteModel website)
        {
            website.LoginID = User.Identity.GetUserId();
            IDBConnector db = DBConnectorFactory.GetDBConnector();

            db.InsertWebsite(website);

            return(RedirectToAction("MyWebsites"));
        }
Пример #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));
        }
Пример #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 }));
        }
Пример #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));
        }
Пример #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));
        }
Пример #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 }));
        }
Пример #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));
        }
Пример #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));
        }
Пример #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));
        }
Пример #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));
        }
Пример #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);
        }
Пример #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);
        }
Пример #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)));
        }
Пример #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);
        }
        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);
        }
Пример #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));
        }
Пример #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));
        }
Пример #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\">");
                }
            }
        }