예제 #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));
        }
예제 #2
0
 public ActionResult DeleteConfirmed(int id)
 {
     FashionShop.Models.EF.News news = db.News.Find(id);
     db.News.Remove(news);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
예제 #3
0
        public ActionResult Create([Bind(Include = "ID,NewName,NewImg,Desciption,Link,Detail,Meta,Hide,Order,Datebegin")] FashionShop.Models.EF.News news)
        {
            if (ModelState.IsValid)
            {
                db.News.Add(news);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(news));
        }
예제 #4
0
 // GET: Admin/News/Edit/5
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     FashionShop.Models.EF.News news = db.News.Find(id);
     if (news == null)
     {
         return(HttpNotFound());
     }
     return(View(news));
 }