Exemple #1
0
        public ActionResult Delete(int id, Picture image)
        {
            var db      = new SedcDatabase();
            var imageId = db.Pictures.FirstOrDefault(c => c.Id == id);

            db.Pictures.Remove(imageId);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #2
0
 public ActionResult Create(Picture picture)
 {
     if (ModelState.IsValid)
     {
         var db = new SedcDatabase();
         db.Pictures.Add(picture);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View("~/Views/Picture/CreateWithHelpers.cshtml", picture));
 }
Exemple #3
0
        public ActionResult Edit(int id, Picture image)
        {
            var db = new SedcDatabase();


            var img = db.Pictures.FirstOrDefault(x => x.Id == id);

            if (img == null)
            {
                return(RedirectToAction("Index"));
            }

            image.DisplayName = image.DisplayName;
            image.Id          = image.Id;
            image.Url         = image.Url;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }