Пример #1
0
        public async Task<JsonResult> GetAllSubMenu(string userName)
        {
            //var userName = "******";
            ApplicationUser user = await UserManager.FindByEmailAsync(userName);
            IEnumerable<SubCategory> currentSubMenus = _categoryService.GetSubMenus(user);
            IEnumerable<MainMenu> mainMenus = _categoryService.GetMainMenus().ToList();
            List<SubCategory> subMenus = new List<SubCategory>();
            foreach ( var mainMenu in mainMenus)
            {
                if(mainMenu.GetSubMenus() != null)
                {
                    foreach (var subMenu in mainMenu.GetSubMenus())
                    {
                        subMenus.Add(subMenu);
                    }
                }
            }
           
            var jsonData = new
            {
                rows = 
                (
                    from m in subMenus
                    select new
                    {
                        Code = m.Code,
                        CodeName = m.ParentCategory.CodeName + " > " + m.CodeName,
                        IsSelected = (currentSubMenus.Count(a => a.Code == m.Code) > 0)
                    }
                )
            };

            return Json(jsonData,JsonRequestBehavior.AllowGet);
        }
Пример #2
0
 public JsonResult SearchMember(GridSettings gridSettings)
 {
     MemberSearchFilter filter = new MemberSearchFilter();
     if (gridSettings.IsSearch)
     {
         filter.Email = gridSettings.Where.rules.Any(r => r.field == "Email") ?
                 gridSettings.Where.rules.FirstOrDefault(r => r.field == "Email").data : string.Empty;
         filter.UserName = gridSettings.Where.rules.Any(r => r.field == "FullName") ?
                 gridSettings.Where.rules.FirstOrDefault(r => r.field == "FullName").data : string.Empty;
     }
     filter.Role = MemberRoles.Contributor;
     int totalRecords = 0;
     var applicationUsers = _memberService.searchMember(filter, gridSettings.SortColumn, gridSettings.SortOrder, gridSettings.PageSize, gridSettings.PageIndex, out totalRecords);
     var jsonData = new
     {
         total = totalRecords / gridSettings.PageSize + 1,
         page = gridSettings.PageIndex,
         records = totalRecords,
         rows = (
             from a in applicationUsers
             select new
             {
                 Id = a.Id,
                 FullName = a.FullName,
                 Email = a.Email,
                 PhoneNumber = a.PhoneNumber,
                 Country = a.Country.CodeName
             }
         )
     };
     return Json(jsonData);
 }