Exemplo n.º 1
0
        public ActionResult EditSection(int id)
        {
            CMSHandler     CMSH = new CMSHandler();
            CMSDataContext db   = new CMSDataContext();

            //Get the only one article to edit
            Section sectionToEdit = db.Sections.Single(p => p.Id == id);

            if (!(Roles.IsUserInRole(sectionToEdit.Role)))
            {
                Session["tempforview"] = "You dont have a permission to edit this article";
                return(RedirectToAction("Login", "Account"));
            }
            //prepare data from db
            SectionModel sectionModel = new SectionModel();

            sectionModel.BakeryId    = sectionToEdit.BakeryId;
            sectionModel.Name        = sectionToEdit.Name;
            sectionModel.Description = sectionToEdit.Description;

            //getdropdown list of roles and select previous role as a default
            sectionModel.Ids   = CMSH.getDropDownListBakeryIDs(int.Parse(Session["id"].ToString()));
            sectionModel.Roles = CMSH.getDropDownListRoles(sectionToEdit.Role);

            return(View(sectionModel));
        }
Exemplo n.º 2
0
        public ActionResult CreateSection()
        {
            SectionModel addmodel = new SectionModel();
            CMSHandler   CMSH     = new CMSHandler();

            //Get dropdowns lists of roles and bakery ids
            addmodel.Ids   = CMSH.getDropDownListBakeryIDs(int.Parse(Session["id"].ToString()));
            addmodel.Roles = CMSH.getDropDownListRoles();

            return(View(addmodel));
        }