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

            //Get the only one article to edit
            Article articleToEdit = db.Articles.Single(p => p.Id == id);

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

            articleModel.bakeryId    = articleToEdit.bakeryId;
            articleModel.Header      = articleToEdit.Header;
            articleModel.Text        = articleToEdit.Text;
            articleModel.Amount      = articleToEdit.Amount;
            articleModel.HoursSpend  = articleToEdit.HoursSpend;
            articleModel.Attachment  = articleToEdit.Attachment;
            articleModel.Description = articleToEdit.Description;

            //getdropdown list and select article's section name as a default
            articleModel.Ids      = CMSH.getDropDownListBakeryIDs(int.Parse(Session["id"].ToString()));
            articleModel.Sections = CMSH.getDropDownListSections(int.Parse(Session["id"].ToString()), articleToEdit.Section.Name);

            return(View(articleModel));
        }
Exemplo n.º 2
0
        public ActionResult CreateArticle()
        {
            CMSHandler   CMSH     = new CMSHandler();
            ArticleModel addmodel = new ArticleModel();

            CMSDataContext        db    = new CMSDataContext();
            List <SelectListItem> files = new List <SelectListItem>();

            //Gets the files to attach from downloads when they are present
            if (Session["network_path"] != null)
            {
                files = CMSH.getDropDownListFiles((int)Session["id"], Session["network_path"].ToString(), Roles.GetRolesForUser());
            }
            ViewBag.FilesToAttach = files;

            addmodel.Ids      = CMSH.getDropDownListBakeryIDs(int.Parse(Session["id"].ToString()));
            addmodel.Sections = CMSH.getDropDownListSections(int.Parse(Session["id"].ToString()));
            return(View(addmodel));
        }