Exemple #1
0
        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());
        }
Exemple #2
0
 public ActionResult Liste()
 {
     using (UrunRepository repo = new UrunRepository())
     {
         var model = repo.GetList();
         return(View(model));
     }
 }
Exemple #3
0
        public JsonResult ListByCategory(int id)
        {
            using (UrunRepository repo = new UrunRepository())
            {
                List <Urun> model = repo.GetList(f => f.KategoriId == id).ToList();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #4
0
        public ActionResult Ekle()
        {
            using (UrunRepository repo = new UrunRepository())
            {
                ViewBag.UrunList = repo.GetList();

                return(View());
            }
        }
        public ActionResult IsletmeUrunEkle()
        {
            Kullanici kullanici = Session["loginSU"] as Kullanici;

            using (UrunRepository repo = new UrunRepository())
            {
                var model = repo.GetList();
                return(View(model));
            }
        }
Exemple #6
0
 public ActionResult Guncelle(int id)
 {
     using (MenuRepository repo = new MenuRepository())
     {
         using (UrunRepository repo2 = new UrunRepository())
         {
             ViewBag.UrunList = repo2.GetList();
         }
         var model = repo.GetOne(f => f.MenuId == 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");
            }
        }