private (Set set, SubmitRequest request) CreateSet() { var set = SetUtility.Create(dbContext); set.Matches = new List <Match>(); setService.Update(set.ID, Arg.Any <MatchForm[]>()).Returns(set); var request = new SubmitRequest { SetID = set.ID }; return(set, request); }
public IActionResult Put(int id, [FromBody] Set set) { try { var b = _setService.Update(set).ToApiModel(); return(Ok(b)); } catch (Exception ex) { ModelState.AddModelError("PutSet", ex.StackTrace); return(BadRequest(ModelState)); } }
public async Task <IActionResult> Submit([FromBody] SubmitRequest request) { try { var set = await setService.Update(request.SetID, request.Matches); dbContext.Entry(set).Reference(s => s.League).Load(); var response = SetDto.Create(set, set.League.GameID); return(CodeResultAndLog(HttpStatusCode.OK, response, $"Set {set.ID} updated.")); } catch (Exception exception) { return(GetExceptionResult(exception, request)); } }
public async Task <IActionResult> Update(int id, [FromBody] UpdateSet model) { var Set = _mapper.Map <Set>(model); Set.Id = id; try { await _setService.Update(Set); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }