public ActionResult DeleteConfirmed(byte id)
        {
            Referances referances = db.Referances.Find(id);

            db.Referances.Remove(referances);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: AdminPanel/Referances/Edit/5
        public ActionResult Edit(byte?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Referances referances = db.Referances.Find(id);

            if (referances == null)
            {
                return(HttpNotFound());
            }
            return(View(referances));
        }
        public ActionResult Create([Bind(Include = "RefId,Title,Image,RefName")] Referances referances, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    ImageUpload imageUpload = new ImageUpload();
                    referances.Image = imageUpload.ImageResize(file, 255, 237);
                }
                db.Referances.Add(referances);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(referances));
        }
Beispiel #4
0
        // GET: Referance/Edit/5


        // GET: Referance/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Referances referances = db.Referances.Find(id);

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

            db.Referances.Remove(referances);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit([Bind(Include = "RefId,Title,Image,RefName")] Referances referances, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                ImageUpload imgUpload = new ImageUpload();
                var         edited    = db.Referances.Find(referances.RefId);
                if (file != null)
                {
                    //resim yükleme işlemi
                    edited.Image = imgUpload.ImageResize(file, 240, 240);
                }

                edited.Title   = referances.Title;
                edited.RefName = referances.RefName;



                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(referances));
        }
Beispiel #6
0
        public ActionResult Create(Referances referances, HttpPostedFileBase Image)
        {
            if (Image != null)
            {
                if (ModelState.IsValid)
                {
                    WebImage img     = new WebImage(Image.InputStream);
                    FileInfo imginfo = new FileInfo(Image.FileName);
                    string   nm      = Image.FileName + imginfo.Extension;
                    img.Resize(600, 400);
                    img.Save("~/Uploads/Referances/" + nm);

                    string a = "/Uploads/Referances/" + nm;

                    referances.Image = a;
                    db.Referances.Add(referances);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(referances));
        }