Example #1
0
        public bool ExistRol(string sDescription)
        {
            var chocorroles = new MenuRol();
            var swap        = chocorroles.getAll();
            var qbo         = (from s in swap where s.sDescription.Equals(sDescription) select s).Count();

            return(qbo >= 1);
        }
Example #2
0
 public void InsertUserRol(string sRol, int iModulo, List <string> lstMenuRol, string sPermisos)
 {
     try
     {
         var ut = new MenuRol();
         var sb = new System.Text.StringBuilder();
         foreach (string menuV in lstMenuRol)
         {
             sb.AppendFormat("{0}|", menuV);
         }
         ut.InsertUserRol(sRol, iModulo, sb.ToString().Substring(0, sb.ToString().Length - 1), sPermisos);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Example #3
0
        public void DeleteRol(int iRol, int iModulo, string sPage)
        {
            var r = new MenuRol();

            r.DeleteRol_Schema(iRol, iModulo, sPage);
        }
Example #4
0
        public List <menuCompositeType> GetMenuPagina(int iIdMenu, int iIdRol)
        {
            var r = new MenuRol();

            return(r.GetMenuPagina(iIdMenu, iIdRol));
        }
Example #5
0
        public DataTable GetMenuPagina(short iMenu)
        {
            var r = new MenuRol();

            return(r.GetMenuPaginas(iMenu));
        }
Example #6
0
        public RolCompositeType GetRolById(int iIdRol)
        {
            var ut = new MenuRol();

            return(ut.GetRolById(iIdRol));
        }
Example #7
0
        public List <menuRolCompositeType> getAllMenuRol(int iIdRol)
        {
            var ut = new MenuRol();

            return(ut.GetMenuRolById(iIdRol));
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            string actionName     = filterContext.ActionDescriptor.ActionName;
            string metot          = filterContext.HttpContext.Request.RequestType;

            if (HttpContext.Current.Session["Kullanici"] == null)
            {
                if ((controllerName != "Kullanici" || controllerName == "Kullanici") && actionName != "Login" && actionName != "SifremiUnuttum")
                {
                    filterContext.Result = new RedirectResult("/Kullanici/Login");
                }
            }
            else
            {
                Personel p = (Personel)HttpContext.Current.Session["Kullanici"];
                if (controllerName == "Admin" && actionName == "Index")
                {
                    return;
                }
                else
                {
                    if (actionName == "MenuGetir")
                    {
                        return;
                    }

                    if (metot == "POST")
                    {
                        IslemErisim currentIslem = db.IslemErisim.Where(x => x.Action == actionName && x.Controller == controllerName).SingleOrDefault();
                        if (currentIslem != null)
                        {
                            ErisimRol rol = db.ErisimRol.Where(x => x.RolID == p.RolID && x.ErisimID == currentIslem.ID).SingleOrDefault();
                            if (rol == null)
                            {
                                if (actionName == "YetkiBulunamadi")
                                {
                                    return;
                                }
                                filterContext.Result = new RedirectResult("/Admin/YetkiBulunamadi");
                            }
                            else
                            {
                                if (controllerName != currentIslem.Controller && actionName != currentIslem.Action)
                                {
                                    filterContext.Result = new RedirectResult("/" + currentIslem.Controller + "/" + currentIslem.Action);
                                }
                                return;
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        Menu currentMenu = db.Menu.Where(x => x.Action == actionName && x.Controller == controllerName).SingleOrDefault();
                        if (currentMenu != null)
                        {
                            MenuRol rol = db.MenuRol.Where(x => x.RolID == p.RolID && x.MenuID == currentMenu.ID).SingleOrDefault();
                            if (rol == null)
                            {
                                if (actionName == "YetkiBulunamadi")
                                {
                                    return;
                                }
                                filterContext.Result = new RedirectResult("/Admin/YetkiBulunamadi");
                            }
                            else
                            {
                                if (controllerName != currentMenu.Controller && actionName != currentMenu.Action)
                                {
                                    filterContext.Result = new RedirectResult("/" + currentMenu.Controller + "/" + currentMenu.Action);
                                }
                                return;
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }
            base.OnActionExecuting(filterContext);
        }
Example #9
0
        public ActionResult Yetkiler(int RolID, string menuler, string islemler, string katrol)
        {
            try
            {
                //, MenuList list , IslemErisimList list2
                Rol r = db.Rol.Where(x => x.ID == RolID).FirstOrDefault(); // Düzenlenmek istenen Rolu bul

                if (r == null)                                             // rol boş ise hata döndür
                {
                    return(RedirectToAction("Hata", "Admin"));
                }

                #region ,Menü Rolleri update
                //Bu role ait tüm yetkileri
                List <MenuRol> menuRol = db.MenuRol.Where(x => x.RolID == r.ID).ToList();


                // Menü rollerinin silinmesi
                foreach (var item in menuRol)
                {
                    db.MenuRol.Remove(item);
                }
                db.SaveChanges(); // roller sıfırlandı.

                //Tüm rolleri yeniden yükle ve değişiklikleri kayıt et.
                string[] Menuparts = menuler.Split('^');
                Array.Reverse(Menuparts);
                List <Menu> Eklenenmenuler = new List <Menu>();
                for (int i = 0; i < Menuparts.Length; i++)
                {
                    string s   = Menuparts[i].ToString();
                    Menu   alt = db.Menu.Where(x => x.Adi == s).FirstOrDefault();
                    if (alt != null)
                    {
                        Eklenenmenuler.Add(alt);
                    }
                }
                foreach (Menu item in Eklenenmenuler)
                {
                    MenuRol rol = new MenuRol();
                    rol.MenuID = item.ID;
                    rol.RolID  = RolID;
                    db.MenuRol.Add(rol);
                    db.SaveChanges();
                }
                // MenuList.RolKontrol(list, RolID);
                ViewBag.Yetkileri = db.MenuRol.Where(x => x.RolID == r.ID).ToList();
                ViewBag.Menuler   = db.Menu.ToList();
                #endregion

                #region ,İşlem Rolleri Update
                //Bu role ait post izinleri
                List <ErisimRol> erisimRol = db.ErisimRol.Where(x => x.RolID == r.ID).ToList();


                // Erisim rollerinin silinmesi
                foreach (var item in erisimRol)
                {
                    db.ErisimRol.Remove(item);
                }
                db.SaveChanges(); // roller sıfırlandı.



                string[]           Islemparts = islemler.Split('^');
                List <IslemErisim> islemlerim = new List <IslemErisim>();
                for (int i = 0; i < Islemparts.Length; i++)
                {
                    string      s      = Islemparts[i].ToString();
                    IslemErisim islemi = db.IslemErisim.Where(x => x.Adı == s).FirstOrDefault();
                    if (islemi != null)
                    {
                        islemlerim.Add(islemi);
                    }
                }

                //Tüm erisimleri yeniden yükle ve değişiklikleri kayıt et.
                foreach (IslemErisim item in islemlerim)
                {
                    ErisimRol rol = new ErisimRol();
                    rol.ErisimID = item.ID;
                    rol.RolID    = RolID;
                    db.ErisimRol.Add(rol);
                    db.SaveChanges();
                }
                #endregion

                #region , ürün Kategori rolleri
                string[]           parts = katrol.Split('^');
                List <AltKategori> alts  = new List <AltKategori>();
                for (int i = 0; i < parts.Length; i++)
                {
                    string      s   = parts[i].ToString();
                    AltKategori alt = db.AltKategori.Where(x => x.KategoriAdi == s).FirstOrDefault();
                    if (alt != null)
                    {
                        alts.Add(alt);
                    }
                }
                List <KategoriRol> kr = db.KategoriRol.Where(x => x.RolID == RolID).ToList();

                foreach (var item in kr) // tüm kategori rollerini sil.
                {
                    db.KategoriRol.Remove(item);
                }
                db.SaveChanges();


                //tüm rolleri yeniden yükle
                foreach (AltKategori item in alts)
                {
                    KategoriRol ktr = new KategoriRol();
                    ktr.RolID      = RolID;
                    ktr.KategoriID = item.ID;
                    db.KategoriRol.Add(ktr);
                    db.SaveChanges();
                }
                #endregion
                //Sayfayı geri yükle
                TempData["GenelMesaj"] = "Profil yetkileri başarılı bir şekilde güncellenmiştir.";
                return(RedirectToAction("ProfilListesi"));
            }
            catch (Exception)
            {
                return(Redirect("/Admin/Hata"));
            }
        }