public ActionResult Create(Slayder s, HttpPostedFileBase file) { try { Slayder _slayder = new Slayder(); if (file != null && file.ContentLength > 0) { MemoryStream memoryStream = file.InputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); file.InputStream.CopyTo(memoryStream); } _slayder.SliderFoto = memoryStream.ToArray(); _slayder.SliderText = s.SliderText; _slayder.SliderSubText = s.SliderSubText; _slayder.OlusturmaTarihi = DateTime.Now; db.slayder.Add(_slayder); db.SaveChanges(); return(RedirectToAction("MySlayder", "Admin")); } return(View(s)); } catch (Exception) { throw new Exception("Hata oluştu"); } }
public ActionResult DeleteConfirmed(int id) { Slayder slayder = db.Slayders.Find(id); db.Slayders.Remove(slayder); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { Slayder _slayder = db.slayder.Find(id); db.slayder.Remove(_slayder); db.SaveChanges(); return(RedirectToAction("MySlayder")); }
public ActionResult Edit([Bind(Include = "slider_id,slider_image,slider_mehsul_id")] Slayder slayder) { if (ModelState.IsValid) { db.Entry(slayder).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.slider_mehsul_id = new SelectList(db.Mallars, "mal_id", "mal_adi", slayder.slider_mehsul_id); return(View(slayder)); }
// GET: Admin/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Slayder _slayder = db.slayder.Find(id); if (_slayder == null) { return(HttpNotFound()); } return(View(_slayder)); }
// GET: Slayders/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Slayder slayder = db.Slayders.Find(id); if (slayder == null) { return(HttpNotFound()); } return(View(slayder)); }
public ActionResult Edit(Slayder s, HttpPostedFileBase file) { try { if (s.SliderText == null || s.SliderSubText == null) { TempData["edit_hata"] = "Tüm alanları doldurun..."; return(View(s)); } Slayder _slayder = new Slayder(); if (file != null && file.ContentLength > 0) { MemoryStream memoryStream = file.InputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); file.InputStream.CopyTo(memoryStream); } _slayder.SliderFoto = memoryStream.ToArray(); } _slayder.ID = s.ID; _slayder.SliderText = s.SliderText; _slayder.SliderSubText = s.SliderSubText; _slayder.OlusturmaTarihi = DateTime.Now; db.Entry(_slayder).State = EntityState.Modified; if (file == null) { db.Entry(_slayder).Property(m => m.SliderFoto).IsModified = false; } db.SaveChanges(); return(RedirectToAction("MySlayder", "Admin")); } catch (Exception) { throw new Exception("Hata oluştu"); } //if (ModelState.IsValid) //{ // db.Entry(_slayder).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("MySlayder"); //} //return View(_slayder); }
// GET: Slayders/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Slayder slayder = db.Slayders.Find(id); if (slayder == null) { return(HttpNotFound()); } ViewBag.slider_mehsul_id = new SelectList(db.Mallars, "mal_id", "mal_adi", slayder.slider_mehsul_id); return(View(slayder)); }
public ActionResult Create(Slayder slayder, HttpPostedFileBase slider_image) { if (ModelState.IsValid) { var file_name = Path.GetFileName(slider_image.FileName); var src = Path.Combine(Server.MapPath("~/Yuklenen"), file_name); slider_image.SaveAs(src); slayder.slider_image = Path.GetFileName(slider_image.FileName); db.Slayders.Add(slayder); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.slider_mehsul_id = new SelectList(db.Mallars, "mal_id", "mal_adi", slayder.slider_mehsul_id); return(View(slayder)); }