Esempio n. 1
0
        public ActionResult Deleteimages(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AdvPhoto advphoto = db.AdvPhotos.Find(id);

            if (advphoto == null)
            {
                return(HttpNotFound());
            }


            db.AdvPhotos.Remove(advphoto);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult Images(int id, HttpPostedFileBase file)
        {
            if (file != null)
            {
                string path = Path.Combine("/Content/images/", file.FileName);
                file.SaveAs(Server.MapPath(path));
                AdvPhoto rsm = new AdvPhoto();
                // Resim bu Modelin
                rsm.AdvPhotoName = file.FileName.ToString();
                // ilişkilendirme
                rsm.AdvId = id;
                db.AdvPhotos.Add(rsm);
                db.SaveChanges();
                return(RedirectToAction("Images"));
            }

            ViewBag.alert = "Please insert Photo.....";
            return(RedirectToAction("Index"));
        }