コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            AnimeImage animeImage = db.AnimeImages.Find(id);

            db.AnimeImages.Remove(animeImage);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "id,anime_img")] AnimeImage animeImage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(animeImage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(animeImage));
 }
コード例 #3
0
        // GET: AdminPanel/AnimeImages/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AnimeImage animeImage = db.AnimeImages.Find(id);

            if (animeImage == null)
            {
                return(HttpNotFound());
            }
            return(View(animeImage));
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "id,anime_img")] AnimeImage animeImage, HttpPostedFileBase anime_img)
        {
            if (ModelState.IsValid)
            {
                Random random       = new Random();
                int    randomNumber = random.Next(0, 100000);
                var    date         = DateTime.Now;
                var    filename     = Path.GetFileName(anime_img.FileName);
                var    src          = Path.Combine(Server.MapPath("~/Uploads/"), randomNumber + filename);
                anime_img.SaveAs(src);
                animeImage.anime_img = "/Uploads/" + randomNumber + filename;
                db.AnimeImages.Add(animeImage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(animeImage));
        }