public ActionResult GetGroupApplications(string Token, int GroupID, int?Page) { var user = CheckUser(Token); if (user == null) { return(Json(new GroupApplications { Code = 500, IsSuccess = false, Info = "AccessToken不正确" })); } if (Page == null) { Page = 0; } var group = DbContext.Groups.Find(GroupID); if ((from gm in @group.GroupMembers where gm.UserID == user.ID && gm.RoleAsInt >= (int)Entity.GroupRole.Master select gm).Count() == 0) { return(Json(new GroupApplications { Code = 802, IsSuccess = false, Info = "您不是该群的管理员" })); } var group_applications = group.GroupJoinApplications.OrderByDescending(x => x.Time).Skip(Page.Value * 10).Take(10).ToList(); var ret = new CodeComb.Models.WebAPI.GroupApplications { Code = 0, IsSuccess = true, List = new List <GroupApplication>(), Info = "", PageCount = group.GroupJoinApplications.Count / 10 + 1 }; foreach (var ga in group_applications) { ret.List.Add(new CodeComb.Models.WebAPI.GroupApplication { ID = ga.ID, GroupID = ga.GroupID, Message = ga.Message, UserID = ga.UserID, StatusAsInt = ga.StatusAsInt, Status = ga.Status.ToString(), Nickname = ga.User.Nickname, AvatarURL = Helpers.Gravatar.GetAvatarURL(ga.User.Gravatar, 180), Response = ga.Response }); } return(Json(ret)); }
public ActionResult GetGroupApplications(string Token, int GroupID, int? Page) { var user = CheckUser(Token); if (user == null) return Json(new GroupApplications { Code = 500, IsSuccess = false, Info = "AccessToken不正确" }); if (Page == null) Page = 0; var group = DbContext.Groups.Find(GroupID); if ((from gm in @group.GroupMembers where gm.UserID == user.ID && gm.RoleAsInt >= (int)Entity.GroupRole.Master select gm).Count() == 0) return Json(new GroupApplications { Code = 802, IsSuccess = false, Info = "您不是该群的管理员" }); var group_applications = group.GroupJoinApplications.OrderByDescending(x=>x.Time).Skip(Page.Value * 10).Take(10).ToList(); var ret = new CodeComb.Models.WebAPI.GroupApplications { Code = 0, IsSuccess = true, List = new List<GroupApplication>(), Info = "", PageCount = group.GroupJoinApplications.Count / 10 + 1 }; foreach (var ga in group_applications) { ret.List.Add(new CodeComb.Models.WebAPI.GroupApplication { ID = ga.ID, GroupID = ga.GroupID, Message = ga.Message, UserID = ga.UserID, StatusAsInt = ga.StatusAsInt, Status = ga.Status.ToString(), Nickname = ga.User.Nickname, AvatarURL = Helpers.Gravatar.GetAvatarURL(ga.User.Gravatar, 180), Response = ga.Response }); } return Json(ret); }