public HttpResponseMessage GetUserBadgeDetail(string id, string badgeName) { if (ValidationService.AuthorizeToken(GetToken(), "get:/api/badge/userbadgedetail?id=&badgename=") == false) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent("无访问权限", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") }); } List <BadgeEntity> badgeEntities = BadgeService.FindAllUserGrantedBadgeEntity(new Guid(id)); foreach (BadgeEntity badgeEntity in badgeEntities) { if (badgeEntity.BadgeName == badgeName) { BadgeDescription badgeDescription = BadgeService.FindBadgeDescriptionByName(badgeEntity.BadgeName); var result = new { badgeName = badgeEntity.BadgeName, badgeDescription = badgeDescription.Description, badgePicture = badgeDescription.Picture, badgeGrantedTime = badgeEntity.GrantedTime, badgeRequirementDescription = badgeDescription.RequirementDescription.Values }; StringWriter tw = new StringWriter(); JsonSerializer jsonSerializer = new JsonSerializer(); jsonSerializer.Serialize(tw, result, result.GetType()); return(new HttpResponseMessage { Content = new StringContent(tw.ToString(), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }); } } return(new HttpResponseMessage { StatusCode = HttpStatusCode.Forbidden, Content = new StringContent("未找到该badge", System.Text.Encoding.GetEncoding("UTF-8"), "application/text") }); }
/// <summary> /// Compute hash of this object based on his properties /// </summary> /// <returns>This object hashcode</returns> public override int GetHashCode() { unchecked { var hashCode = AccountId.GetHashCode(); hashCode = (hashCode * 397) ^ (AccountName != null ? AccountName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ BadgeId.GetHashCode(); hashCode = (hashCode * 397) ^ (BadgeDescription != null ? BadgeDescription.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// 将BadgeEntity集合转换成用于列表显示 /// </summary> /// <param name="source"></param> /// <returns></returns> private List <object> transformBadgeEntityToListShow(IEnumerable <BadgeEntity> source) { List <object> result = new List <object>(); foreach (BadgeEntity badgeEntity in source) { BadgeDescription badgeDescription = BadgeService.FindBadgeDescriptionByName(badgeEntity.BadgeName); var listShow = new { badgeName = badgeEntity.BadgeName, badgeDescription = badgeDescription.Description, badgePicture = badgeDescription.Picture }; result.Add(listShow); } return(result); }
void ReleaseDesignerOutlets() { if (BadgeName != null) { BadgeName.Dispose(); BadgeName = null; } if (BadgeDescription != null) { BadgeDescription.Dispose(); BadgeDescription = null; } if (BadgeImage != null) { BadgeImage.Dispose(); BadgeImage = null; } }