public ActionResult SearchKullaniciYetki(string searchAdi, string searchSoyadi, int? page)
        {
            var Jr = new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            var KullaniciList = baglanti().Select<Kullanici>();

            if (!string.IsNullOrEmpty(searchAdi))
            {
                KullaniciList = KullaniciList.Where(p => p.adi.ToLower().Contains(searchAdi)).ToList();
            }

            if (!string.IsNullOrEmpty(searchSoyadi))
            {
                KullaniciList = KullaniciList.Where(p => p.soyadi.ToLower().Contains(searchSoyadi)).ToList();
            }

            var Match = new YetkilendirmeViewModel()
            {

            };

            Match.Kullanicilar = KullaniciList;

            if (KullaniciList != null)
            {
                var Result = RenderPartialViewToString("YetkilendirmeList", Match);
                Jr.Data = new[] { new { Status = "ok", results = Result, searchAdi = searchAdi } };
            }

            return Jr;
        }
        public ActionResult YetkiAl(int KullaniciId, YetkilendirmeViewModel Match)
        {
            var Jr = new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            if (Request.IsAjaxRequest() && KullaniciId > 0)
            {

                Match.GrupUyelikleri = baglanti().Select<KullaniciGrup>().Where(p => p.kullanici_id == KullaniciId).Select(p => p.grup_id).ToArray();

                var KullYukle = baglanti().Select<Kullanici>().Where(p => p.id == KullaniciId).ToList();

                Jr.Data = new[] { new { Status = "ok", Result = KullYukle, ResultYetki = Match } };

            }

            return Jr;
        }
        public ActionResult YetkiDuzenle(YetkilendirmeViewModel Match, int KullaniciId, int[] GrupId)
        {
            var Jr = new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            if (GrupId == null)
            {
                Jr.Data = new[] { new { Status = "er", Mesaj = "Yetki Grubunu Seçiniz !" } };
                return Jr;
            }

            try
            {
                var mevcutGrupUyelikleri = baglanti().Select<KullaniciGrup>().Where(p => p.kullanici_id == KullaniciId).ToList();

                var secilenGruplar = Match.Gruplar.Where(p => GrupId.Contains(p.id)).ToList();
                var silinecekGrupUyelikleri = mevcutGrupUyelikleri.Where(p => !secilenGruplar.Select(g => g.id).Contains(p.grup_id)).ToList();

                if (silinecekGrupUyelikleri != null)
                {
                    foreach (var item in silinecekGrupUyelikleri)
                    {
                        baglanti().Delete(item);
                    }

                }

                for (int i = 0; i < GrupId.Count(); i++)
                {
                    var GetKullaniciId = baglanti().GetById<Kullanici>(KullaniciId);
                    var GetGrupId = baglanti().GetById<Grup>(GrupId[i]);

                    var Yetki = (Match.Id > 0) ? baglanti().GetById<KullaniciGrup>(Match.Id) : new KullaniciGrup();

                    if (Yetki.id == 0)
                    {
                        Yetki.kullanici_id = GetKullaniciId.id;
                        Yetki.grup_id = GetGrupId.id;
                        baglanti().Insert(Yetki);
                    }
                    else
                    {
                        Yetki.grup_id = GetGrupId.id;
                        baglanti().Update(Yetki);
                    }
                }
            }
            catch (Exception ex)
            {
                Jr.Data = new[] { new { Status = "er", Mesaj = ex.Message.ToString() } };
                return Jr;
            }

            var vm = new YetkilendirmeViewModel()
            {
                Kullanicilar = baglanti().Select<Kullanici>().ToList()
            };

            Jr.Data = new[] { new { Status = "ok", Result = RenderPartialViewToString("YetkilendirmeList", vm) } };
            return Jr;
        }
        public ActionResult Yetkilendirme()
        {
            var Match = new YetkilendirmeViewModel()
            {
                Kullanicilar = baglanti().Select<Kullanici>(),
                Gruplar = baglanti().Select<Grup>()
            };

            return View(Match);
        }