Exemple #1
0
        /// <summary>
        /// Add the role.
        /// </summary>
        /// <param name="role">role object.</param>
        /// <returns>Adds the role</returns>
        public bool Add_Role(C_Role role)
        {
            using (var data = new Entities())
            {
                bool rt;
                try
                {
                    data.C_Role.Add(role);
                    data.SaveChanges();
                    rt = true;
                }
                catch (Exception)
                {
                    rt = false;
                }

                return(rt);
            }
        }
Exemple #2
0
        /// <summary>
        /// Edits the role.
        /// </summary>
        /// <param name="role">role object.</param>
        /// <returns>Edits the role</returns>
        public bool Edit_Role(C_Role role)
        {
            using (var data = new Entities())
            {
                bool rt;
                try
                {
                    var c_gen = data.C_Role.Where(p => p.ID == role.ID).FirstOrDefault();
                    c_gen.Role     = role.Role;
                    c_gen.RoleName = role.RoleName;
                    c_gen.Des      = role.Des;
                    data.SaveChanges();
                    rt = true;
                }
                catch (Exception)
                {
                    rt = false;
                }

                return(rt);
            }
        }
Exemple #3
0
 public static int AddRole(C_Role role)
 {
     throw new NotImplementedException();
 }
Exemple #4
0
 public frmAddUserToGroup()
 {
     InitializeComponent();
     usr = new C_Role();
 }
Exemple #5
0
 public frmRole()
 {
     InitializeComponent();
     usr = new C_Role();
 }
Exemple #6
0
        public ActionResult Index()
        {
            if (!this.CheckAdminlogin())
            {
                return(this.RedirectToAction("login", "dashboard", new { area = "admin" }));
            }
            else
            {
                var return_url = Request.Url.ToString();
                var index_view = new Index_view();
                int count      = Request.QueryString.Count;
                if (count > 0)
                {
                    string act, ctrl, type_act, type;
                    act      = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : string.Empty;
                    ctrl     = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : string.Empty;
                    type_act = Request.QueryString["type_act"] != null ? Request.QueryString["type_act"].ToString() : CommonGlobal.View;
                    type     = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : string.Empty;
                    if (act != string.Empty && ctrl != string.Empty)
                    {
                        bool       isOk  = false;
                        UserModels sv    = new UserModels();
                        RoleModels roleM = new RoleModels();
                        C_Role     itR   = new C_Role();
                        C_User     itU   = new C_User();

                        itU = sv.GetUserbyUserName(Session["mem"].ToString());
                        itR = roleM.GetRoleItem(itU.Role);
                        ////check permission view/add/edit
                        if (ctrl == "adminProduct" && (act == "image_product" || act == "property_product" || act == "list_Rating"))
                        {
                            ////Chỉ được phép thay đổi thuộc tính của sản phẩm nếu có quyền edit product
                            if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, "change_product", ctrl, type_act, type) && itR.Role == "Admin")
                            {
                                isOk = true;
                            }
                            else
                            {
                                isOk = false;
                            }
                        }
                        else
                        {
                            if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type) && itR.Role == "Admin")
                            {
                                isOk = true;
                            }
                            else
                            {
                                isOk = false;
                            }
                        }

                        if (isOk == true)
                        {
                            index_view.Act      = act;
                            index_view.Ctrl     = ctrl;
                            index_view.Type_act = type_act;
                            index_view.Type     = type;
                        }
                        else
                        {
                            logger.Error(Session["mem"].ToString() + " đã truy cập khu vực không hợp lệ:act = " + act + ",ctrl = " + ctrl + ",type_act= " + type_act + ",type= " + type);
                            index_view.Act  = "access_denied";
                            index_view.Ctrl = "dashboard";
                        }
                    }
                    else
                    {
                        logger.Error(Session["mem"].ToString() + " đã truy cập khu vực không hợp lệ:act = " + act + ",ctrl = " + ctrl + ",type_act= " + type_act + ",type= " + type);
                        index_view.Act  = "access_denied";
                        index_view.Ctrl = "dashboard";
                    }
                }
                else
                {
                    index_view.Act      = "statistic";
                    index_view.Ctrl     = "dashboard";
                    index_view.Type_act = CommonGlobal.View;
                    index_view.Type     = string.Empty;
                }

                index_view.Return_url = return_url;

                return(this.PartialView("../page/index", index_view));
            }
        }