Esempio n. 1
0
        public void CreateBadge()
        {
            Badge b = new Badge {
                Id = 12, Name = "Test Subject", Description = "You made a passing unit test!"
            };
            long bID = _badgeService.CreateBadge(b).Result;

            Assert.AreEqual(b.Id, bID);
        }
Esempio n. 2
0
        public async Task <ActionResult <BadgeResource> > CreateBadge(SaveBadgeResource badge)
        {
            var badgeToCreate = _mapper.Map <SaveBadgeResource, Badge>(badge);
            var createdBadge  = await _badgeService.CreateBadge(badgeToCreate);

            var badgeToReturn = _mapper.Map <Badge, BadgeResource>(createdBadge);

            return(Ok(badgeToReturn));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> PostBadge(Badge badge)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            badge.Id = await _badgeService.CreateBadge(badge);

            return(CreatedAtRoute("DefaultApi", new { id = badge.Id }, badge));
        }
Esempio n. 4
0
        public void Update(Badge badge)
        {
            List <BadgeResponse> userBadge = badgeService.GetBadgeByUserId(badge.UserID);

            foreach (BadgeResponse b in userBadge)
            {
                if (b.Name == badge.Name)
                {
                    return;
                }
            }
            badgeService.CreateBadge(badge);
        }
Esempio n. 5
0
 /// <summary>
 /// Creates new Badge object in database
 /// </summary>
 /// <param name="badge">new Badge</param>
 public void CreateBadge(Badge badge)
 {
     _badgeService.CreateBadge(badge);
 }