public async Task HadRound_WithValidModelReturns() { var createUserResponse = await PostAndAssert($"{RootBrewApiPath}/newpersonhadbrew", _httpClient, true); var converter = new ExpandoObjectConverter(); dynamic user = JsonConvert.DeserializeObject <ExpandoObject>(createUserResponse, converter); var response = await PostAndAssert($"{RootRoundApiPath}/new", DummyRoundModel(user.simpleId), _httpClient, true); var createdRound = Newtonsoft.Json.JsonConvert.DeserializeObject <RoundSummaryModel>(response); var model = new HadRoundModel { Id = createdRound.Id, UserGettingRound = "7EmMT6n3f0i/YniN6osJXQ==", RoundNotes = "Fixture Round" }; var hasRoundResponse = await PostAndAssert($"{RootRoundApiPath}/hadround", model, _httpClient, true); JsonAssert.EqualOverrideDefault(@"{ ""roundDescription"": ""Integration Test Round"", ""roundLocationName"": ""Bespin Feasting Table"" }" , hasRoundResponse , new JsonDiffConfig(true) ); }
public async Task <IActionResult> HadRound([FromBody] HadRoundModel model) { if (!ModelState.IsValid) { return(ReturnError(StatusCodes.Status400BadRequest, "Invalid had round request", GetModelStateMessages())); } var round = await _dataStore.GetAsync <Round>(model.Id); if (round == null) { return(ReturnError(StatusCodes.Status404NotFound, "Invalid had round request", $"Round {model.Id} not found")); } if (!round.CanUpdateRound(User)) { return(ReturnError(StatusCodes.Status403Forbidden, "Invalid had round request", $"You are not allowed to update this round")); } await _roundService.UpdateExistingRoundAsync(round, _dataStore, model.UserGettingRound, model.RoundNotes); return(Ok(RoundSummaryModel.FromRound(round))); }