public ActionResult GetGroups(string Token, int?Page) { var user = CheckUser(Token); if (user == null) { return(Json(new Groups { List = null, Code = 500, IsSuccess = false, Info = "AccessToken不正确" })); } if (Page == null) { Page = 0; } IEnumerable <Entity.Group> groups = (from g in DbContext.Groups where (from m in g.GroupMembers where m.UserID == user.ID select m).Count() > 0 orderby g.ID ascending select g); var ret = new CodeComb.Models.WebAPI.Groups { IsSuccess = true, Code = 0, Info = "", List = new List <Group>(), PageCount = groups.Count() / 10 + 1 }; groups = groups.Skip(Page.Value * 10).Take(10).ToList(); foreach (var group in groups) { ret.List.Add(new CodeComb.Models.WebAPI.Group { ID = group.ID, Description = group.Description, Icon = Helpers.Gravatar.GetAvatarURL(group.Icon, 180), MemberCount = group.GroupMembers.Count, Title = group.Title }); } return(Json(ret)); }
public ActionResult GetGroups(string Token, int? Page) { var user = CheckUser(Token); if (user == null) return Json(new Groups { List = null, Code = 500, IsSuccess = false, Info = "AccessToken不正确" }); if(Page == null) Page = 0; IEnumerable<Entity.Group> groups = (from g in DbContext.Groups where (from m in g.GroupMembers where m.UserID == user.ID select m).Count() > 0 orderby g.ID ascending select g); var ret = new CodeComb.Models.WebAPI.Groups { IsSuccess = true, Code = 0, Info = "", List = new List<Group>(), PageCount = groups.Count() / 10 + 1 }; groups = groups.Skip(Page.Value * 10).Take(10).ToList(); foreach (var group in groups) { ret.List.Add(new CodeComb.Models.WebAPI.Group { ID = group.ID, Description = group.Description, Icon = Helpers.Gravatar.GetAvatarURL(group.Icon, 180), MemberCount = group.GroupMembers.Count, Title = group.Title }); } return Json(ret); }