// GET: api/UserBadges?badgeId=2 public IEnumerable <UserBadgeDto> GetUserBadges(long badgeId) { var ubs = ubsvc.GetUserBadges(badgeId); var ubDtos = ubs.Select(t => UserBadgeDto.FromUserBadge(t)); return(ubDtos); }
// GET: api/UserBadges?userId=xyz public IEnumerable <UserBadgeDto> GetUserBadges(String userId) { if (userId == "current") { userId = User.Identity.GetUserId(); } var ubs = ubsvc.GetUserBadges(userId); var ubDtos = ubs.Select(t => UserBadgeDto.FromUserBadge(t)); return(ubDtos); }
public IHttpActionResult PostUserBadge(UserBadge ub) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ubsvc.CreateUserBadge(ub); uow.Save(); return(CreatedAtRoute("DefaultApi", new { id = ub.ID }, UserBadgeDto.FromUserBadge(ub))); }
public IHttpActionResult GetUserBadge(String userId, long badgeId) { var ub = ubsvc.GetUserBadge(badgeId, userId); if (ub == null) { return(NotFound()); } var ubDto = UserBadgeDto.FromUserBadge(ub); return(Ok(ubDto)); }
public IHttpActionResult GetUserBadge(long id) { var ub = ubsvc.GetUserBadge(id); if (ub == null) { return(NotFound()); } var ubDto = UserBadgeDto.FromUserBadge(ub); return(Ok(ubDto)); }