public async Task <JsonResult> CommunityDetail(long?id, bool?edit) { if (CurrentUserId == 0) { await TryAuthenticateFromHttpContext(); } var communityDetails = await _communityService.GetCommunityDetails(id.Value, CurrentUserId, true, true); var permissionDetails = GetUserPermissionDetails(id.Value, PermissionsTab.Users, 0); if (edit == true) { var communityInputViewModel = new CommunityInputViewModel(); Mapper.Map(communityDetails, communityInputViewModel); var json = new { community = communityInputViewModel, permission = permissionDetails }; return(Json(json, JsonRequestBehavior.AllowGet)); } var communityViewModel = new CommunityViewModel(); Mapper.Map(communityDetails, communityViewModel); if (communityViewModel.AccessType != AccessType.Private || communityViewModel.UserPermission >= Permission.Reader) { var json = new { community = communityViewModel, permission = permissionDetails }; return(Json(json, JsonRequestBehavior.AllowGet)); } return(new JsonResult { Data = new { communityViewModel.Name, communityViewModel.Id, error = "insufficient permission" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }