Beispiel #1
0
        public ActionResult Edit([Bind(Include = "ID,NewName,NewImg,Desciption,Link,Detail,Meta,Hide,Order,Datebegin")] FashionShop.Models.EF.News news, HttpPostedFileBase img)
        {
            var filename = "";
            var path     = "";

            FashionShop.Models.EF.News temp = new FashionShop.Models.DAO.News().getById(news.ID);
            if (ModelState.IsValid)
            {
                if (img != null)
                {
                    filename = img.FileName;
                    path     = Path.Combine(Server.MapPath("~/Images/Products/"), filename);

                    img.SaveAs(path);
                    temp.NewImg = filename;
                }

                temp.NewName    = news.NewName;
                temp.Desciption = news.Desciption;
                temp.Detail     = news.Detail;
                temp.Meta       = news.Meta;
                temp.Hide       = news.Hide;
                temp.Order      = news.Order;
                temp.Datebegin  = news.Datebegin;

                db.Entry(temp).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(news));
        }
Beispiel #2
0
        // GET: Admin/News
        public ActionResult Index(int?page)
        {
            var pageNumber = page ?? 1;
            var news       = new FashionShop.Models.DAO.News().show();

            return(View(news.ToPagedList(pageNumber, 3)));
        }