public ActionResult Create(Product product, HttpPostedFileBase UrunResmi) { if (ModelState.IsValid) { string directory = Server.MapPath("~/Img/Product/"); if (UrunResmi != null && UrunResmi.ContentLength > 0) { var fileName = Path.GetFileName(UrunResmi.FileName); UrunResmi.SaveAs(Path.Combine(directory, fileName)); product.UrunResmi = UrunResmi.FileName; } if (product.UrunStok < 0) { product.UrunStok = 0; } if (product.UrunFiyati < 0) { product.UrunFiyati = 0; } product.EklenmeTarihi = DateTime.Now; db.Product.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Category, "Id", "KategoriAdi", product.CategoryId); return(View(product)); }
public Urun AddUrun(Urun urun) { var addUrun = _urunContext.Urunler.Add(urun); _urunContext.SaveChanges(); return(urun); }
public ActionResult Create([Bind(Include = "Id,UstKategoriId,KategoriAdi,KategoriAciklamasi")] Category category) { if (ModelState.IsValid) { db.Category.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Kayit(User Kullanici) { if (ModelState.IsValid) { Kullanici.EklenmeTarihi = DateTime.Now; db.User.Add(Kullanici); db.SaveChanges(); return(RedirectToAction("/giris")); } return(View(Kullanici)); }
public ActionResult Create(User user) { if (ModelState.IsValid) { user.EklenmeTarihi = DateTime.Now; db.User.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create(Entities.Admin admin) { if (ModelState.IsValid) { admin.EklenmeTarihi = DateTime.Now; db.Admin.Add(admin); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(admin)); }
public ActionResult Create(Slider slider, HttpPostedFileBase Resim) { if (ModelState.IsValid) { string directory = Server.MapPath("~/Img/Slider/"); if (Resim != null && Resim.ContentLength > 0) { var fileName = Path.GetFileName(Resim.FileName); Resim.SaveAs(Path.Combine(directory, fileName)); slider.Resim = Resim.FileName; } db.Slider.Add(slider); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(slider)); }
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(); } }
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; }