Example #1
0
        public void EditMenuTest()
        {
            var obj = MenuDAO.GetAll().Find(x => x.ID == 1);

            obj.Nome      = "Teste3";
            obj.Descricao = "Teste3";
            obj.Url       = "Teste/teste";

            var result = MenuDAO.Save(obj);
        }
 public async Task <IEnumerable <Menu> > GetAllMenu(int idCliente, string token)
 {
     if (await Seguranca.validaTokenAsync(token))
     {
         return(MenuDAO.GetAll().Where(x => x.idCliente == idCliente).ToList());
     }
     else
     {
         return(new List <Menu>());
     }
 }
Example #3
0
        void Start()
        {
            TableDAO tableDAO = new TableDAO();
            OrderDAO orderDAO = new OrderDAO();
            MenuDAO  menuDAO  = new MenuDAO();

            //menuDAO.Insert(915, "Secret menu", new TimeSpan(10, 10, 10), new TimeSpan(10, 20, 20));

            List <Menu> menus = menuDAO.GetAll();

            Console.WriteLine(menus);
            Console.ReadKey();
        }
        public async Task <JsonResult> DeletarMenu([FromBody] object Menu, string token)
        {
            dynamic objEn = Menu;
            string  a     = objEn.idMenu.ToString();

            if (await Seguranca.validaTokenAsync(token))
            {
                Menu obj = MenuDAO.GetAll().Where(x => x.ID == Convert.ToInt32(a)).FirstOrDefault();
                return(Json(new { msg = MenuDAO.Remove(obj) }));
                //return Json(new { msg = false });
            }
            else
            {
                return(Json(new { msg = false }));
            }
        }
Example #5
0
        public override Task <MenuTree> GetUserMenus(KeyObject request, ServerCallContext context)
        {
            var id = Convert.ToInt64(request.Body);

            var allMenus = _menuDao.GetAll();

            var userPermissionMenus     = new List <Menu>();
            var userPermissionLeafMenus = _userDao.GetUserMenus(id);

            foreach (var m in userPermissionLeafMenus)
            {
                userPermissionMenus.Add(m);
                var temp = new List <Menu>();
                FindParentMenus(allMenus, temp, m);
                userPermissionMenus.AddRange(temp);
            }
            userPermissionMenus = userPermissionMenus.Distinct(new MenuEqualityComparer()).ToList();

            var response        = new MenuTree();
            var firstLevelMenus = userPermissionMenus
                                  .Where(s => string.IsNullOrEmpty(s.ParentCode))
                                  .OrderBy(s => s.Code)
                                  .Select(s => new MenuNode()
            {
                Code       = s.Code,
                ParentCode = s.ParentCode,
                Path       = s.Path,
                Name       = s.Name,
                Icon       = s.Icon,
                IsLeaf     = s.IsLeaf
            }).ToList();

            response.Nodes.AddRange(firstLevelMenus);
            BuildMenuTree(userPermissionMenus, response.Nodes.ToList());

            return(Task.FromResult(response));
        }
 public List <Menu> GetMenus() => menuDAO.GetAll();
Example #7
0
 public void RemoveMenuTest()
 {
     var obj    = MenuDAO.GetAll().Find(x => x.ID == 1);
     var result = MenuDAO.Remove(obj);
 }
Example #8
0
 public void GetAllMenuTest()
 {
     var resut = MenuDAO.GetAll();
 }