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); }
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)); }
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)); }
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); }
/// <summary> /// Creates new Badge object in database /// </summary> /// <param name="badge">new Badge</param> public void CreateBadge(Badge badge) { _badgeService.CreateBadge(badge); }