コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Mehsul mehsul = db.Mehsuls.Find(id);

            db.Mehsuls.Remove(mehsul);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "mehsul_id,mehsulun_adi,mehsulun_linki,mehsulun_sekli,mehsul_qiymeti,mehsul_price")] Mehsul mehsul)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mehsul).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(mehsul));
 }
コード例 #3
0
        // GET: Mehsullar/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Mehsul mehsul = db.Mehsuls.Find(id);

            if (mehsul == null)
            {
                return(HttpNotFound());
            }
            return(View(mehsul));
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "mehsul_id,mehsulun_adi,mehsulun_linki,mehsul_qiymeti,mehsul_price")] Mehsul mehsul, HttpPostedFileBase mehsulun_sekli)
        {
            if (ModelState.IsValid)
            {
                if (Path.GetExtension(mehsulun_sekli.FileName) == ".jpg" || Path.GetExtension(mehsulun_sekli.FileName) == ".jpeg" || Path.GetExtension(mehsulun_sekli.FileName) == ".png")
                {
                    var file_name = Path.GetFileName(mehsulun_sekli.FileName);
                    var src       = Path.Combine(Server.MapPath("/MyUpload"), file_name);
                    mehsulun_sekli.SaveAs(src);
                }
                mehsul.mehsulun_sekli = Path.GetFileName(mehsulun_sekli.FileName);
                db.Mehsuls.Add(mehsul);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mehsul));
        }