public ActionResult Create([Bind(Include = "Id,Name,UrlKeyWord,ThumbnailUrl,Brief,Desc,ShowInMainMenu,Url,CatalogParentId,Publish,Order")] Catalog catalog)
        {
            if (ModelState.IsValid)
            {
                catalog.DateCreated = DateTime.Now;
                db.Catalogs.Add(catalog);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CatalogParentId = new SelectList(CatalogResolve.GetSelectListAllLevelCatalog(db.Catalogs.Where(c => c.CatalogParentId == null).ToList()), "Id", "Name");
            return(View(catalog));
        }
 public ActionResult Edit([Bind(Include = "Id,Name,UrlKeyWord,ThumbnailUrl,Brief,Desc,ShowInMainMenu,Url,CatalogParentId,Publish,Order")] Catalog catalog)
 {
     if (ModelState.IsValid)
     {
         var update = db.Catalogs.Find(catalog.Id);
         if (TryUpdateModel(update, new[] { "Id", "Name", "UrlKeyWord", "ThumbnailUrl", "Brief", "Desc", "ShowInMainMenu", "Url", "CatalogParentId", "Publish", "Order" }))
         {
             db.Entry(update).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     ViewBag.CatalogParentId = new SelectList(CatalogResolve.GetSelectListAllLevelCatalog(db.Catalogs.Where(c => c.CatalogParentId == null).ToList()), "Id", "Name");
     return(View(catalog));
 }
예제 #3
0
        // GET: DNSAdmin/ArticleManager/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var article = db.Articles.Find(id);

            if (article == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Catalogs = CatalogResolve.GetSelectListAllLevelCatalog(db.Catalogs.Where(c => c.CatalogParentId == null).ToList());
            return(View(article));
        }
예제 #4
0
        public ActionResult Create(Article article, int[] catalogIds)
        {
            if (catalogIds != null)
            {
                article.Catalogs = db.Catalogs.Where(c => catalogIds.Any(id => id.Equals(c.Id))).ToList();
            }
            if (ModelState.IsValid)
            {
                article.Type        = ArticleType.Article;
                article.DateCreated = article.PublishedDate = DateTime.Now;
                db.Articles.Add(article);
                db.SaveChanges();
                return(article.Publish ? RedirectToAction("Index") : RedirectToAction("Edit", new { id = article.Id }));
            }

            ViewBag.Catalogs = CatalogResolve.GetSelectListAllLevelCatalog(db.Catalogs.Where(c => c.CatalogParentId == null).ToList());
            return(View(article));
        }
        // GET: DNSAdmin/CatalogManager/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var catalog = db.Catalogs.Find(id);

            if (catalog == null)
            {
                return(HttpNotFound());
            }
            var selectlist = CatalogResolve.GetSelectListAllLevelCatalog(db.Catalogs.Where(c => c.CatalogParentId == null).ToList()).Select(o => new
            {
                o.Id,
                Name = GetName(o.Name, o.Level)
            });

            ViewBag.CatalogParentId = new SelectList(selectlist, "Id", "Name", catalog.CatalogParentId.HasValue?catalog.CatalogParentId.Value: 0);
            return(View(catalog));
        }
 // GET: DNSAdmin/CatalogManager/Create
 public ActionResult Create()
 {
     ViewBag.CatalogParentId = new SelectList(CatalogResolve.GetSelectListAllLevelCatalog(db.Catalogs.Where(c => c.CatalogParentId == null).ToList()), "Id", "Name");
     return(View());
 }
예제 #7
0
 // GET: DNSAdmin/ArticleManager/Create
 public ActionResult Create()
 {
     ViewBag.Catalogs = CatalogResolve.GetSelectListAllLevelCatalog(db.Catalogs.Where(c => c.CatalogParentId == null).ToList());
     return(View(new Article()));
 }