コード例 #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));
        }
コード例 #2
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));
        }
コード例 #3
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));
        }
コード例 #4
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));
        }
コード例 #5
0
        public ActionResult EditSection(int id, SectionModel collection)
        {
            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"));
            }
            sectionToEdit.BakeryId    = collection.BakeryId;
            sectionToEdit.Name        = collection.Name;
            sectionToEdit.Description = collection.Description;
            sectionToEdit.Role        = collection.Role;

            db.SubmitChanges();

            return(RedirectToAction("Index"));
        }
コード例 #6
0
        public override void Execute()
        {
            #line 3 "..\..\Views\CMS\Index.cshtml"

            ViewBag.Title = "List of Articles";
            string lastSectionName = "";
            string fileName        = "";


            #line default
            #line hidden
            WriteLiteral("\r\n\r\n<h3>List of articles</h3>\r\n");


            #line 10 "..\..\Views\CMS\Index.cshtml"
            if (User.IsInRole("CMS"))
            {
            #line default
            #line hidden
                WriteLiteral("    <p>\r\n");

                WriteLiteral("        ");


            #line 13 "..\..\Views\CMS\Index.cshtml"
                Write(Html.ActionLink("Create new Section", "CreateSection", new { }, new { @class = "btn btn-xs btn-primary" }));


            #line default
            #line hidden
                WriteLiteral("\r\n    </p>\r\n");

                WriteLiteral("    <p>\r\n");

                WriteLiteral("        ");


            #line 16 "..\..\Views\CMS\Index.cshtml"
                Write(Html.ActionLink("Create new Article", "CreateArticle", new { }, new { @class = "btn btn-xs btn-primary" }));


            #line default
            #line hidden
                WriteLiteral("\r\n    </p>\r\n");

                WriteLiteral("    <p>\r\n");

                WriteLiteral("        ");


            #line 19 "..\..\Views\CMS\Index.cshtml"
                Write(Html.ActionLink("List of sections", "Sections", new { }, new { @class = "btn btn-xs btn-primary" }));


            #line default
            #line hidden
                WriteLiteral("\r\n    </p>\r\n");


            #line 21 "..\..\Views\CMS\Index.cshtml"
            }


            #line default
            #line hidden

            #line 22 "..\..\Views\CMS\Index.cshtml"



            #line default
            #line hidden

            #line 23 "..\..\Views\CMS\Index.cshtml"
            if (Model != null)
            {
            #line default
            #line hidden
                WriteLiteral("    <div");

                WriteLiteral(" class=\"table-responsive\"");

                WriteLiteral(">\r\n        <table");

                WriteLiteral(" class=\"table table-condensed table-bordered table-hover table-responsive\"");

                WriteLiteral(">\r\n            <tr >\r\n                <th");

                WriteLiteral(" class=\"col-md-2\"");

                WriteLiteral("style=\"text-align: center;\"");

                WriteLiteral(" title=\"Date and time when was it created\"");

                WriteLiteral(">\r\n                    Created\r\n                </th>\r\n                <th");

                WriteLiteral(" style=\"text-align: center;\"");

                WriteLiteral(" title=\"Author\"");

                WriteLiteral(">\r\n                    Aut.\r\n                </th>\r\n                <th");

                WriteLiteral(" style=\"text-align: center;\"");

                WriteLiteral(" title=\"Subject\"");

                WriteLiteral(">\r\n                    Subj.\r\n                </th>\r\n                <th");

                WriteLiteral(" style=\"text-align: center;\"");

                WriteLiteral(" class=\"col-md-4\"");

                WriteLiteral(" title=\"Article text\"");

                WriteLiteral(">\r\n                    Content\r\n                </th>\r\n                <th");

                WriteLiteral(" style=\"text-align: center;\"");

                WriteLiteral(" title=\"Cots of our services\"");

                WriteLiteral(">\r\n                    Costs\r\n                </th>\r\n                <th");

                WriteLiteral(" style=\"text-align: center;\"");

                WriteLiteral(" title=\"Hours spend\"");

                WriteLiteral(">\r\n                    Hs.\r\n                </th>\r\n                <th");

                WriteLiteral(" style=\"text-align: center;\"");

                WriteLiteral(" class=\"col-md-1\"");

                WriteLiteral(" >\r\n                    Attachment\r\n                </th>\r\n                <th");

                WriteLiteral(" style=\"text-align: center;\"");

                WriteLiteral(" title=\"Attachment description\"");

                WriteLiteral(">\r\n                    Desciption\r\n                </th>\r\n                <th></t" +
                             "h>\r\n            </tr>\r\n");


            #line 53 "..\..\Views\CMS\Index.cshtml"


            #line default
            #line hidden

            #line 53 "..\..\Views\CMS\Index.cshtml"
                foreach (var item in Model)
                {
                    if (item.Section.Name != lastSectionName)
                    {
            #line default
            #line hidden
                        WriteLiteral("                <tr>\r\n");


            #line 58 "..\..\Views\CMS\Index.cshtml"


            #line default
            #line hidden

            #line 58 "..\..\Views\CMS\Index.cshtml"

                        lastSectionName = item.Section.Name;


            #line default
            #line hidden
                        WriteLiteral("\r\n                    <td");

                        WriteLiteral(" colspan=\"5\"");

                        WriteLiteral(" style=\"border-left:0px; border-right: 0px;\"");

                        WriteLiteral("><h4><u>");


            #line 61 "..\..\Views\CMS\Index.cshtml"
                        Write(Html.DisplayFor(modelItem => item.Section.Name));


            #line default
            #line hidden
                        WriteLiteral("</u></h4></td>\r\n                </tr>\r\n");


            #line 63 "..\..\Views\CMS\Index.cshtml"
                    }


            #line default
            #line hidden
                    WriteLiteral("                <tr");

                    WriteLiteral(" class=\"small\"");

                    WriteLiteral(">\r\n                    <td>\r\n");

                    WriteLiteral("                        ");


            #line 66 "..\..\Views\CMS\Index.cshtml"
                    Write(Html.Raw(CMSHandler.maxLength(item.DateTime.ToString(), 40, "/CMS/DetailArticle/" + item.Id)));


            #line default
            #line hidden
                    WriteLiteral("\r\n                    </td>\r\n                    <td>\r\n");

                    WriteLiteral("                        ");


            #line 69 "..\..\Views\CMS\Index.cshtml"
                    Write(Html.DisplayFor(modelItem => item.Author));


            #line default
            #line hidden
                    WriteLiteral("\r\n                    </td>\r\n                    <td>\r\n");

                    WriteLiteral("                        ");


            #line 72 "..\..\Views\CMS\Index.cshtml"
                    Write(Html.Raw(CMSHandler.maxLength(item.Header, 40, "/CMS/DetailArticle/" + item.Id)));


            #line default
            #line hidden
                    WriteLiteral("\r\n                    </td>\r\n                    <td>\r\n");

                    WriteLiteral("                        ");


            #line 75 "..\..\Views\CMS\Index.cshtml"
                    Write(Html.Raw(CMSHandler.maxLength(item.Text, 55, "/CMS/DetailArticle/" + item.Id)));


            #line default
            #line hidden
                    WriteLiteral("\r\n                    </td>\r\n                    <td>\r\n");

                    WriteLiteral("                        ");


            #line 78 "..\..\Views\CMS\Index.cshtml"
                    Write(Html.Raw(CMSHandler.maxLength(item.Amount, 10, "/CMS/DetailArticle/" + item.Id)));


            #line default
            #line hidden
                    WriteLiteral("\r\n                    </td>\r\n                    <td>\r\n");

                    WriteLiteral("                        ");


            #line 81 "..\..\Views\CMS\Index.cshtml"
                    Write(Html.Raw(CMSHandler.maxLength(item.HoursSpend.ToString(), 10, "/CMS/DetailArticle/" + item.Id)));


            #line default
            #line hidden
                    WriteLiteral("\r\n                    </td>\r\n                    <td>\r\n");


            #line 84 "..\..\Views\CMS\Index.cshtml"


            #line default
            #line hidden

            #line 84 "..\..\Views\CMS\Index.cshtml"
                    if (item.Attachment != null)
                    {
                        if (item.Attachment.Contains('/'))
                        {
                            fileName = item.Attachment.Substring(item.Attachment.LastIndexOf('/'));
                        }


            #line default
            #line hidden
                        WriteLiteral("                            <a");

                        WriteAttribute("href", Tuple.Create(" href=\"", 3848), Tuple.Create("\"", 3903)
                                       , Tuple.Create(Tuple.Create("", 3855), Tuple.Create("/Download/downloadFile?nameFile=", 3855), true)

            #line 90 "..\..\Views\CMS\Index.cshtml"
                                       , Tuple.Create(Tuple.Create("", 3887), Tuple.Create <System.Object, System.Int32>(item.Attachment

            #line default
            #line hidden
                                                                                                                         , 3887), false)
                                       );

                        WriteAttribute("title", Tuple.Create(" title=\"", 3904), Tuple.Create("\"", 3921)

            #line 90 "..\..\Views\CMS\Index.cshtml"
                                       , Tuple.Create(Tuple.Create("", 3912), Tuple.Create <System.Object, System.Int32>(fileName

            #line default
            #line hidden
                                                                                                                         , 3912), false)
                                       );

                        WriteLiteral(">Download</a>\r\n");


            #line 91 "..\..\Views\CMS\Index.cshtml"
                    }


            #line default
            #line hidden
                    WriteLiteral("                    </td>\r\n                    <td>\r\n");

                    WriteLiteral("                        ");


            #line 94 "..\..\Views\CMS\Index.cshtml"
                    Write(Html.Raw(CMSHandler.maxLength(item.Description, 20, "/CMS/DetailArticle/" + item.Id)));


            #line default
            #line hidden
                    WriteLiteral("\r\n                    </td>\r\n                    <td>\r\n                        <s" +
                                 "pan> ");


            #line 97 "..\..\Views\CMS\Index.cshtml"
                    Write(Html.ActionLink("Details", "DetailArticle", new { id = item.Id }));


            #line default
            #line hidden
                    WriteLiteral(" </span>\r\n");


            #line 98 "..\..\Views\CMS\Index.cshtml"


            #line default
            #line hidden

            #line 98 "..\..\Views\CMS\Index.cshtml"
                    if (User.IsInRole("CMS"))
                    {
            #line default
            #line hidden
                        WriteLiteral("                            <span>| ");


            #line 100 "..\..\Views\CMS\Index.cshtml"
                        Write(Html.ActionLink("Edit", "EditArticle", new { id = item.Id }));


            #line default
            #line hidden
                        WriteLiteral(" |</span>\r\n");


            #line 101 "..\..\Views\CMS\Index.cshtml"



            #line default
            #line hidden
                        WriteLiteral("                            <span>");


            #line 102 "..\..\Views\CMS\Index.cshtml"
                        Write(Html.ActionLink("Delete", "DeleteArticle", new { id = item.Id }));


            #line default
            #line hidden
                        WriteLiteral("</span>\r\n");


            #line 103 "..\..\Views\CMS\Index.cshtml"
                    }


            #line default
            #line hidden
                    WriteLiteral("                    </td>\r\n                </tr>\r\n");


            #line 106 "..\..\Views\CMS\Index.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("        </table>\r\n    </div>\r\n");


            #line 109 "..\..\Views\CMS\Index.cshtml"
            }
            else
            {
            #line default
            #line hidden
                WriteLiteral("    <div");

                WriteLiteral(" class=\"col-md-offset-3\"");

                WriteLiteral(">\r\n       <h4><b>No articles to this bakery has been found</b></h4>\r\n    </div>\r\n" +
                             "");


            #line 114 "..\..\Views\CMS\Index.cshtml"
            }

            #line default
            #line hidden
        }