public ActionResult Index() { Kullanici user = Session["loginSU"] as Kullanici; KategoriMenuUrunKullaniciModel model = new KategoriMenuUrunKullaniciModel(); if (user.Yetki == (int)EnumYetki.Admin) { using (KategoriRepository repo = new KategoriRepository()) { model.KategoriList = repo.GetList(); } using (MenuRepository repo = new MenuRepository()) { model.MenuList = repo.GetList(); } using (UrunRepository repo = new UrunRepository()) { model.UrunList = repo.GetList(); } using (KullaniciRepository repo = new KullaniciRepository()) { model.KullaniciList = repo.GetList(); } return(View(model)); } else if (user.Yetki == (int)EnumYetki.Isletme) { using (IsletmeUrunRepository repo = new IsletmeUrunRepository()) { ViewBag.IsletmeUrunList = repo.IsletmeninUrunleri(user.KullaniciId); } } return(View()); }
public ActionResult IsletmeUrunSil(int id) { Kullanici kullanici = Session["loginSU"] as Kullanici; using (IsletmeUrunRepository repo = new IsletmeUrunRepository()) { bool result = repo.Delete(id); TempData["Message"] = result == true ? new TempDataDictionary { { "class", "alert alert-success" }, { "msg", "Ürün Silindi" } } : new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", "Ürün Silinemedi" } }; return(RedirectToAction("IsletmeUrunListe")); } }
public ActionResult Index(int id) { //KategoriMenuUrunModel allList = new KategoriMenuUrunModel(); //using (UrunRepository repo = new UrunRepository()) //{ // allList.UrunList = repo.GetList(); //} //using (KategoriRepository repo = new KategoriRepository()) //{ // allList.KategoriList = repo.GetList(); //} //using (MenuRepository repo = new MenuRepository()) //{ // allList.MenuList = repo.GetList(); //} //using (MenuUrunRepository repo = new MenuUrunRepository()) //{ // ViewBag.MenuUrunList = repo.GetList(); //} //using (IsletmeAyarRepository repo = new IsletmeAyarRepository()) //{ // ViewBag.IsletmeAyar = repo.GetOne(f => f.isActive == true); //} List <Kategori> kategoriList = new List <Kategori>(); using (IsletmeUrunRepository repo = new IsletmeUrunRepository()) { var model = repo.IsletmeninUrunleri(id); using (KategoriRepository repo2 = new KategoriRepository()) { //kategoriList = repo2.GetList(); foreach (var item in model) { var deneme = repo2.GetOne(f => f.KategoriId == item.Urun.KategoriId); if (!kategoriList.Contains(deneme)) { kategoriList.Add(deneme); } } } ViewBag.KategoriList = kategoriList; return(View(model)); } }
public ActionResult IsletmeUrunListe(int?id) { if (id == null) { Kullanici kullanici = Session["loginSU"] as Kullanici; using (IsletmeUrunRepository repo = new IsletmeUrunRepository()) { ICollection <IsletmeUrun> model = repo.IsletmeninUrunleri(kullanici.KullaniciId); return(View(model)); } } else { using (IsletmeUrunRepository repo = new IsletmeUrunRepository()) { ICollection <IsletmeUrun> model = repo.IsletmeninUrunleri((int)id); return(View(model)); } } }
public void IsletmeUrunEkle(/*int[] model,string[] obj*/ string model) { IsletmeUrunEkleModel b = (IsletmeUrunEkleModel)Newtonsoft.Json.JsonConvert.DeserializeObject(model, typeof(IsletmeUrunEkleModel)); Kullanici kullanici = Session["loginSU"] as Kullanici; //List<int> eklenecekler = new List<int>(); using (IsletmeUrunRepository repo = new IsletmeUrunRepository()) { var olanlar = repo.GetList(f => f.KullaniciId == kullanici.KullaniciId); foreach (var item in b.IsletmeUrunEkleModelList) { if (olanlar.Any(f => f.UrunId == item.Id)) { b.IsletmeUrunEkleModelList.Remove(item); } } List <int> result = repo.UrunleriEkle(b, kullanici.KullaniciId); if (result.Count() == 0) { TempData["Message"] = new TempDataDictionary { { "class", "alert alert-success" }, { "msg", "Ürünler eklendi." } }; } else { List <Urun> eklenemeyenUrunler = new List <Urun>(); using (UrunRepository repo2 = new UrunRepository()) { foreach (var item in result) { eklenemeyenUrunler = repo2.GetList(f => f.UrunId == item).ToList(); } } TempData["Message"] = new TempDataDictionary { { "class", "alert alert-danger" }, { "msg", $"{result.Count()} ürün eklenemedi" } }; ViewBag.EklenemeyenUrunler = eklenemeyenUrunler; } //return RedirectToAction("IsletmeUrunEkle"); } }