public ActionResult Duzenle(int? id) { using (UrunContext ctx = new UrunContext()) { var mus = ctx.Musteriler.Find(id); return View(mus); } }
public ActionResult Sil(int? id) { using (UrunContext ctx = new UrunContext()) { var mus = ctx.Musteriler.Find(id); ctx.Musteriler.Remove(mus); ctx.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Duzenle(Musteri mus) { using (UrunContext ctx = new UrunContext()) { ctx.Entry(mus).State = EntityState.Modified; int sonuc = ctx.SaveChanges(); if (sonuc > 0) { return RedirectToAction("Index"); } return View(); } }
// GET: Musteri public ActionResult Index() { using (UrunContext ctx = new UrunContext()) { MusteriViewModel ovm = new MusteriViewModel(); ovm.Musteriler = ctx.Musteriler.ToList(); return View(ovm); } }
public bool Ekle(Musteri o) { if (ModelState.IsValid)//bu dogrulama düzenlede de olmalı projede { using (UrunContext ctx = new UrunContext()) { ctx.Musteriler.Add(o); int sonuc = ctx.SaveChanges(); if (sonuc > 0) { return true; } } } return false; }
public UrunIslemleri(UrunContext urunContext) { _urunContext = urunContext; }