Esempio n. 1
0
        // 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);
        }
Esempio n. 2
0
        // 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);
        }
Esempio n. 3
0
        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)));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        public IHttpActionResult GetUserBadge(long id)
        {
            var ub = ubsvc.GetUserBadge(id);

            if (ub == null)
            {
                return(NotFound());
            }
            var ubDto = UserBadgeDto.FromUserBadge(ub);

            return(Ok(ubDto));
        }