Exemplo n.º 1
0
        public ActionResult UpdateActiveStatus(int entryid, bool isactive)
        {
            IDbConnection db = new OrmliteConnection().openConn();

            try
            {
                var isExist = AuthMenu.GetById(entryid, null, false);
                isExist.isactive  = isactive;
                isExist.updatedby = currentUser.entryid;
                isExist.updatedat = DateTime.Now;
                db.UpdateOnly(isExist,
                              onlyFields: p =>
                              new
                {
                    p.isactive,
                    p.updatedat,
                    p.updatedby
                },
                              where : p => p.entryid == entryid);
                return(Json(new { success = true }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
            finally { db.Close(); }
        }
Exemplo n.º 2
0
        public void TheAppMustShowTheDashboardWhenAServiceAgentLogsIn()
        {
            var loginPage = new LoginPage(webDriver);

            loginPage
            .UsernameField
            .SendKeys(TestData.CustomerServiceUser.Username);

            loginPage
            .PasswordField
            .SendKeys(TestData.CustomerServiceUser.Password);

            loginPage.LoginButton.Click();

            var authMenu  = new AuthMenu(webDriver);
            var loginWait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(5));

            loginWait.Until(_ => authMenu.NameLabel != null);

            Check.That(authMenu.NameLabel.Text).IsEqualTo(TestData.CustomerServiceUser.Name);
            Check.That(authMenu.RoleLabel.Text).IsEqualTo("Customer Service Agent");

            webDriver.FindElement(ByEx.PartialText("Clients"));
            webDriver.FindElement(ByEx.PartialText("Policies"));
        }
Exemplo n.º 3
0
        public ActionResult Read([DataSourceRequest] DataSourceRequest request, string isactive)
        {
            string whereCondition = "";

            if (request.Filters.Count > 0)
            {
                whereCondition = " AND " + new KendoApplyFilter().ApplyFilter(request.Filters[0]);
            }
            //var UserType = 1;//1: backend|2: card-holder|3: pos
            var userid = 0;
            var data   = new AuthMenu().GetPage(request, whereCondition, isactive, userid);

            return(Json(data));
        }
Exemplo n.º 4
0
        public static Dictionary <string, bool> GetViewData()
        {
            Dictionary <string, bool> dictView = new Dictionary <string, bool>();
            var listAllMenu = new AuthMenu().GetAllMenu("en");

            foreach (var i in listAllMenu)
            {
                if (!dictView.ContainsKey("menu_" + i.menuid))
                {
                    dictView.Add("menu_" + i.menuid, true);
                }
            }
            return(dictView);
        }
Exemplo n.º 5
0
        public JsonResult AuthMenus(int moudleId, int menuId, int btnId, AuthMenu dto)
        {
            var res = new Result <int>();

            foreach (var roleId in dto.RoleIds)
            {
                roleMenuService.Delete(item => item.RoleId == roleId);
                var newRoleMenus = dto.MenuIds.Select(item => new RoleMenu {
                    RoleId = roleId, MenuId = item
                }).ToList();
                roleMenuService.Add(newRoleMenus);
            }

            res.flag = true;

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public ActionResult GetByID(int entryid)
        {
            IDbConnection dbConn = new OrmliteConnection().openConn();

            try
            {
                var data      = AuthMenu.GetById(entryid, null, false);
                var ref_Roles = CustomModel.GetActiveStatus();
                return(Json(new
                {
                    success = true,
                    data = data
                }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
            finally { dbConn.Close(); }
        }
Exemplo n.º 7
0
        public ActionResult Create(AuthMenu item)
        {
            IDbConnection db = new OrmliteConnection().openConn();

            try
            {
                if (string.IsNullOrEmpty(item.entryname) || string.IsNullOrEmpty(item.entrycode))
                {
                    return(Json(new { success = false, message = tw_Lang.Common_ActionResult_MissingInfo }));
                }
                var isExist = AuthMenu.GetById(item.entryid, null, false);

                //Validate

                //insert / update
                if (item.entryid == 0)
                {
                    //insert
                    item.createdat = DateTime.Now;
                    item.createdby = currentUser.entryid;
                    item.updatedat = DateTime.Now;
                    item.updatedby = currentUser.entryid;
                    item.isactive  = true;
                }
                else
                {
                    //update
                    item.createdby = isExist.createdby;
                    item.updatedat = DateTime.Now;
                    item.updatedby = currentUser.entryid;
                }
                item.AddOrUpdate(currentUser.entryid, null, false);
                return(Json(new { success = true, data = item }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
            finally { db.Close(); }
        }
Exemplo n.º 8
0
        public void TheAppMustAllowTheUserToLogOut()
        {
            var loginPage = new LoginPage(webDriver);

            loginPage
            .UsernameField
            .SendKeys(TestData.CustomerServiceUser.Username);

            loginPage
            .PasswordField
            .SendKeys(TestData.CustomerServiceUser.Password);

            loginPage.LoginButton.Click();

            var authMenu  = new AuthMenu(webDriver);
            var loginWait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(5));

            loginWait.Until(_ => authMenu.SignOutButton);

            authMenu.SignOutButton.Click();
            Check.That(loginPage.UsernameField).IsNotNull();
            Check.That(loginPage.PasswordField).IsNotNull();
        }
Exemplo n.º 9
0
        public AuthMenu GetAuthMenuList(string url, MenuType type = MenuType.Menu, MenuColumnType columnType = MenuColumnType.CONDITION)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(new AuthMenu());
            }
            url = url.ToLower();
            var list = this.GetAuthList();

            if (list != null && list.Count() > 0)
            {
                var tempList = list.Where(m =>
                {
                    if (string.IsNullOrEmpty(m.URL))
                    {
                        return(false);
                    }
                    string[] urls = m.URL.Split('|');
                    bool flag     = false;
                    foreach (var item in urls)
                    {
                        flag = string.Equals(item, url, StringComparison.InvariantCultureIgnoreCase);
                        if (flag)
                        {
                            break;
                        }
                    }
                    return(flag);
                });
                if (type == MenuType.Menu)
                {
                    return(new AuthMenu(tempList));
                }
                else if (type == MenuType.Button)
                {
                    AuthMenu am     = new AuthMenu();
                    int      menuId = 0;
                    if (tempList != null && tempList.Count() > 0)
                    {
                        int menuType = (int)type;
                        var menu     = tempList.FirstOrDefault();
                        am.Menus = list.Where(m => m.PARENTID == menu.ID && m.TYPE == menuType);
                        //查找 按钮 为 查询 或 下载的 菜单
                        if (am.Menus != null)
                        {
                            string btn_code = columnType == MenuColumnType.CONDITION ? WebConst.MENU_BUTTON_CODE_CONDITION : WebConst.MENU_BUTTON_CODE_REPORT;
                            var    obj      = am.Menus.FirstOrDefault(m => string.Equals(m.CODE, btn_code, StringComparison.InvariantCultureIgnoreCase));
                            if (obj != null)
                            {
                                menuId = obj.ID;
                            }
                        }
                    }
                    int uid = log.User.ID;
                    if (menuId > 0)
                    {
                        am.Columns = menuRep.GetAuthColumnList(menuId, uid, columnType);
                    }
                    return(am);
                }
            }
            return(new AuthMenu());
        }