// Menu public override Task <GetMenusResponse> GetMenus(GetMenusRequest request, ServerCallContext context) { var menus = _menuDao.GetMenus(request.ParentCode); var res = new GetMenusResponse(); res.Menus.AddRange(menus.Select(m => _mapper.Map <MenuDTO>(m))); return(Task.FromResult(res)); }
public GetMenusResponse GetMenusForGrid(GetMenusRequest request) { int totalRecords; var menus = SortData(request.Search, request.SortingDictionary, out totalRecords); if (request.Take != -1) { menus = menus.Skip(request.Skip).Take(request.Take); } var response = new GetMenusResponse(); response.Menus = menus.ToList().MapTo <GetMenusResponse.Menu>(); response.TotalRecords = totalRecords; return(response); }
public GetMenusResponse GetMenus(GetMenusRequest request) { IQueryable <Data.Entities.Menu> menus; if (request.Take != 0) { menus = DataContext.Menus.OrderBy(x => x.Order).Skip(request.Skip).Take(request.Take); } else { menus = DataContext.Menus; } var response = new GetMenusResponse() { Menus = menus.MapTo <GetMenusResponse.Menu>() }; return(response); }
private void GetTreeChildren(IList <Menu> entitys, IList <GetMenusResponse> results, string parentId = null) { IList <Menu> result = null; if (string.IsNullOrEmpty(parentId)) { result = entitys.Where(p => string.IsNullOrEmpty(p.ParentId)).ToList(); } else { result = entitys.Where(p => p.ParentId == parentId).ToList(); } foreach (var t1 in result) { var res = new GetMenusResponse { Id = t1.Id, ParentId = t1.ParentId, Title = t1.Name, Value = t1.Id, Key = t1.Id, Name = t1.Name, Path = t1.Path, Sort = t1.Sort, Status = t1.Status, Level = t1.Level, CreatedOn = t1.CreatedOn, UpdatedOn = t1.UpdatedOn, IsInside = t1.IsInside }; if (entitys.Any(p => p.ParentId == t1.Id)) { res.Children = new List <GetMenusResponse>(); GetTreeChildren(entitys, res.Children, t1.Id); } results.Add(res); } }