Example #1
0
            //front end
            public static Core.Models.Page Retrieve(string t, string s = "", string p = "")
            {
                DB.Context db = new DB.Context();
                IRepository<Core.Models.Page> repo = new DB.Repository<Core.Models.Page>(db);

                //tab link
                if (!string.IsNullOrEmpty(t))
                {
                    Tab tab = db.Tabs.SingleOrDefault(x => x.UrlTitle.Equals(t));
                    if (tab != null)
                    {
                        if (!string.IsNullOrEmpty(s))
                        {
                            Section sec = tab.Sections.SingleOrDefault(x => x.UrlTitle.Equals(s));
                            if (sec != null)
                            {
                                if (!string.IsNullOrEmpty(p))
                                {
                                    Link l = sec.Links.SingleOrDefault(x => x.UrlTitle.Equals(p));
                                    if (l != null)
                                    {
                                        //return Link Page
                                        return repo.RetrieveById(l.PageId);
                                    }
                                    else
                                    {
                                        return null;
                                    }
                                }
                                else
                                {
                                    //return Section Page
                                    return repo.RetrieveById(sec.PageId);
                                }
                            }
                            else
                            {
                                return null;
                            }
                        }
                        else
                        {
                            //return Tab Page
                            return repo.RetrieveById(tab.PageId);
                        }
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    //home page
                    return repo.SingleOrDefault(x => x.IsHomePage == true);
                }
            }
Example #2
0
 public static AuthenticatedUser FindUser(string email, string hashedPassword)
 {
     DB.Context db = new DB.Context();
     string activeStatus = Enums.Status.Account.Active.ToString();
     Account acc = db.Accounts.SingleOrDefault(x => x.Email.Equals(email) && x.Password == hashedPassword && x.Status.Equals(activeStatus));
     if (acc != null)
     {
         return new AuthenticatedUser(acc.Id, String.Format("{0} {1}", acc.FirstName, acc.LastName), (Security.Role)Enum.Parse(typeof(Security.Role), acc.SecurityRole));
     }
     return null;
 }
Example #3
0
        public ActionResult ForgotPassword(string email, string returnUrl)
        {
            if (email.Length > 0)
            {
                if (Utils.Validate.EmailAddress(email))
                {
                    DB.Context db = new DB.Context();
                    Account acc = db.Accounts.SingleOrDefault(x => x.Email.Equals(email));
                    if (acc != null)
                    {
                        string randomPassword = Security.Password.GenerateRandom();
                        string password = Security.Password.GenerateHash(email, randomPassword);

                        acc.Password = password;

                        try
                        {
                            db.SaveChanges();
                            //send email reminder
                            Utils.Email.sendEmail(Config.ActiveConfiguration.Mail.From, acc.Email, "Password Reminder", "Your new password is: " + randomPassword, true, Config.ActiveConfiguration.Mail.Host, Config.ActiveConfiguration.Mail.Port);
                        }
                        catch
                        {
                            ViewData["ErrorMessage"] = "An error occurred. Please try again";
                        }

                        ViewData["returnUrl"] = returnUrl;
                        return View("PasswordEmailed");
                    }
                    else
                    {
                        //no matching email
                        ViewData["ErrorMessage"] = "Email provided does not match any of our records";
                    }
                }
                else
                {
                    //invalid email
                    ViewData["ErrorMessage"] = "Email format is not valid";
                }
            }
            else
            {
                //no email
                ViewData["ErrorMessage"] = "Email is required";
            }

            return View();
        }
Example #4
0
        public ActionResult SaveAccordionItemsOrder(int pageId, string order, string delim, string jsonp = "")
        {
            Api.Response api = new Api.Response();
            List<Error.Message> error = new List<Error.Message>();

            string[] arr = Utils.Array.FromString(order, delim);

            DB.Context db = new DB.Context();
            IRepository<Accordion> repo = new DB.Repository<Accordion>(db);
            IEnumerable<Accordion> data = repo.Retrieve(x => x.PageId == pageId, m => m.OrderBy(x => x.Position), null);
            int ctr = 1;
            foreach (string id in arr)
            {
                try
                {
                    Accordion item = data.Single(x => x.Id == Convert.ToInt32(id));
                    item.Position = ctr;
                    repo.Update(item);
                    ctr++;
                }
                catch (Exception ex)
                {
                    Error.Exception(ex, "/API/Engine/SaveAccordionItemsOrder PageID: " + pageId.ToString() + " ID: " + id);
                }
            }

            try
            {
                repo.Save();
                api.Success = true;
            }
            catch (Exception exc)
            {
                Error.Exception(exc, "AccordionPage/SaveOrder");
                error.Add(new Error.Message { Id = "", Text = Config.Error.Message.Generic });
                api.Success = false;
                api.Errors = error;
            }

            if (!string.IsNullOrEmpty(jsonp))
            {
                return new Api.Response.Jsonp(api, jsonp);
            }
            else
            {
                return Json(api, JsonRequestBehavior.DenyGet);
            }
        }
 public StaticPageController()
 {
     this.db = new DB.Context();
     this.repo = new DB.Repository<StaticPage>(this.db);
 }
Example #6
0
 public NavTabController()
 {
     this.db = new DB.Context();
     this.repo = new DB.Repository<Tab>(this.db);
 }
Example #7
0
                    public static MultiSelectList Accordions(int pageId, int? selectedID)
                    {
                        List<SelectListItem> list = new List<SelectListItem>();
                        List<int> selectedValues = new List<int>();
                        DB.Context db = new DB.Context();
                        IRepository<Accordion> repo = new DB.Repository<Accordion>(db);
                        IEnumerable<Accordion> data = repo.Retrieve(x => x.PageId == pageId, m => m.OrderBy(x => x.Position), null);
                        if (data.Count() > 0)
                        {
                            foreach (Accordion item in data)
                            {
                                list.Add(new SelectListItem
                                {
                                    Text = item.Header,
                                    Value = item.Id.ToString(),
                                    Selected = ((selectedID != null) ? ((item.Id.Equals((int)selectedID)) ? true : false) : ((item.Id.Equals(data.First().Id)) ? true : false))
                                });
                            }

                            selectedValues.Add(((selectedID != null) ? (int)selectedID : data.First().Id));
                        }

                        return new MultiSelectList(list, "Value", "Text", selectedValues);
                    }
Example #8
0
                    public static MultiSelectList Links(int sectionID, int? selectedID)
                    {
                        List<SelectListItem> list = new List<SelectListItem>();
                        List<int> selectedValues = new List<int>();
                        DB.Context db = new DB.Context();
                        IRepository<Link> repo = new DB.Repository<Link>(db);
                        IEnumerable<Link> links = repo.Retrieve(x => x.SectionId == sectionID, m => m.OrderBy(x => x.Position), null);
                        if (links.Count() > 0)
                        {
                            foreach (Link lnk in links)
                            {
                                list.Add(new SelectListItem
                                {
                                    Text = lnk.Title,
                                    Value = lnk.Id.ToString(),
                                    Selected = ((selectedID != null) ? ((lnk.Id.Equals((int)selectedID)) ? true : false) : ((lnk.Id.Equals(links.First().Id)) ? true : false))
                                });
                            }

                            selectedValues.Add(((selectedID != null) ? (int)selectedID : links.First().Id));
                        }
                        return new MultiSelectList(list, "Value", "Text", selectedValues);
                    }
Example #9
0
                    public static MultiSelectList Sections(int tabID, int? selectedID)
                    {
                        List<SelectListItem> list = new List<SelectListItem>();
                        List<int> selectedValues = new List<int>();
                        DB.Context db = new DB.Context();
                        IRepository<Section> repo = new DB.Repository<Section>(db);
                        IEnumerable<Section> sections = repo.Retrieve(x => x.TabId == tabID, m => m.OrderBy(x => x.Position), null);
                        if (sections.Count() > 0)
                        {
                            foreach (Section s in sections)
                            {
                                list.Add(new SelectListItem
                                {
                                    Text = s.Title,
                                    Value = s.Id.ToString(),
                                    Selected = ((selectedID != null) ? ((s.Id.Equals((int)selectedID)) ? true : false) : ((s.Id.Equals(sections.First().Id)) ? true : false))
                                });
                            }

                            selectedValues.Add(((selectedID != null) ? (int)selectedID : sections.First().Id));
                        }

                        return new MultiSelectList(list, "Value", "Text", selectedValues);
                    }
Example #10
0
                    public static MultiSelectList Tabs(int? selectedID)
                    {
                        List<SelectListItem> list = new List<SelectListItem>();
                        List<int> selectedValues = new List<int>();
                        DB.Context db = new DB.Context();
                        IRepository<Tab> repo = new DB.Repository<Tab>(db);
                        IEnumerable<Tab> tabs = repo.Retrieve(null, m => m.OrderBy(x => x.Position), null);
                        if (tabs.Count() > 0)
                        {
                            foreach (Tab t in tabs)
                            {
                                list.Add(new SelectListItem
                                {
                                    Text = t.Title,
                                    Value = t.Id.ToString(),
                                    Selected = ((selectedID != null) ? ((t.Id.Equals((int)selectedID)) ? true : false) : ((t.Id.Equals(tabs.First().Id)) ? true : false))
                                });
                            }

                            selectedValues.Add(((selectedID != null) ? (int)selectedID : tabs.First().Id));
                        }
                        return new MultiSelectList(list, "Value", "Text", selectedValues);
                    }
Example #11
0
            public static Security.Role GetSecurityRoleById(int id)
            {
                DB.Context db = new DB.Context();
                Account acc = db.Accounts.SingleOrDefault(x => x.Id == id);
                if (acc != null)
                {
                    return (Security.Role)Enum.Parse(typeof(Security.Role), acc.SecurityRole);
                }

                return Security.Role.User;
            }
 public AccordionPageController()
 {
     this.db = new DB.Context();
     this.repo = new DB.Repository<Accordion>(this.db);
 }
 public CustomPageController()
 {
     this.db = new DB.Context();
     this.repo = new DB.Repository<CustomPage>(this.db);
 }
 public ComponentController()
 {
     this.db = new DB.Context();
     this.repo = new DB.Repository<PageComponent>(this.db);
 }
Example #15
0
 public NavLinkController()
 {
     this.db = new DB.Context();
     this.repo = new DB.Repository<Link>(this.db);
 }
 public NavSectionController()
 {
     this.db = new DB.Context();
     this.repo = new DB.Repository<Section>(this.db);
 }