Beispiel #1
0
        public ActionResult Edit(int id, Yuzme yüzme, HttpPostedFileBase ResimURL)
        {
            if (ModelState.IsValid)
            {
                var b = db.Yuzme.Where(x => x.YuzmeId == id).SingleOrDefault();
                if (ResimURL != null)
                {
                    if (System.IO.File.Exists(Server.MapPath(b.ResimURL)))
                    {
                        System.IO.File.Delete(Server.MapPath(b.ResimURL));
                    }
                    WebImage img     = new WebImage(ResimURL.InputStream);
                    FileInfo imginfo = new FileInfo(ResimURL.FileName);

                    string yuzmeimgname = Guid.NewGuid().ToString() + imginfo.Extension;
                    img.Resize(600, 400);
                    img.Save("~/Uploads/Yüzme/" + yuzmeimgname);

                    b.ResimURL = "/Uploads/Yüzme/" + yuzmeimgname;
                }
                b.Baslik     = yüzme.Baslik;
                b.Icerik     = yüzme.Icerik;
                b.KategoriId = yüzme.KategoriId;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(yüzme));
        }
Beispiel #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Yuzme yüzme = db.Yuzme.Find(id);

            db.Yuzme.Remove(yüzme);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Yuzme yüzme = db.Yuzme.Find(id);

            if (yüzme == null)
            {
                return(HttpNotFound());
            }
            return(View(yüzme));
        }
Beispiel #4
0
        public ActionResult Create(Yuzme yüzme, HttpPostedFileBase ResimURL)
        {
            if (ResimURL != null)
            {
                WebImage img     = new WebImage(ResimURL.InputStream);
                FileInfo imginfo = new FileInfo(ResimURL.FileName);

                string yuzmeimgname = Guid.NewGuid().ToString() + imginfo.Extension;
                img.Resize(600, 400);
                img.Save("~/Uploads/Yüzme/" + yuzmeimgname);

                yüzme.ResimURL = "/Uploads/Yüzme/" + yuzmeimgname;
            }
            db.Yuzme.Add(yüzme);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }