public async Task <IActionResult> CreateAsync([FromBody] Client.Maraphone.MaraphoneBuildInfo buildInfo, CancellationToken cancellationToken) { if (buildInfo == null) { var error = ServiceErrorResponses.BodyIsMissing("MaraphoneBuildInfo"); return(this.BadRequest(error)); } var userId = User.FindFirstValue("userId"); if (userId == null) { var error = ServiceErrorResponses.InvalidClaims("userId"); return(this.BadRequest(error)); } var maraphoneCreationInfo = new MaraphoneCreationInfo(buildInfo, userId); var modelMaraphone = await maraphoneRepository.CreateAsync(maraphoneCreationInfo, cancellationToken); var clientMaraphone = MaraphoneConverter.Convert(modelMaraphone); return(CreatedAtRoute( "GetMaraphone", new { id = clientMaraphone.Id }, clientMaraphone)); }
public async Task <IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken) { if (id == null) { var error = ServiceErrorResponses.InvalidRouteParameter("maraphoneId"); return(this.BadRequest(error)); } var modelMaraphone = await maraphoneRepository.GetAsync(id, cancellationToken); if (modelMaraphone == null) { var message = "Maraphone with id " + id + " not found."; var error = ServiceErrorResponses.NoSuchObject("Maraphone", message); return(this.NotFound(error)); } var clientMaraphone = MaraphoneConverter.Convert(modelMaraphone); return(Ok(clientMaraphone)); }