Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. [HttpPost]
  2. public IActionResult postValue(League league)
  3. {
  4. if(league==null){
  5. return BadRequest("bad object format was given");
  6. }
  7. if(context.Leagues.FirstOrDefault(x => x.id==league.id)!=null)
  8. {
  9. //var value = context.Users.FirstOrDefault(x => x.id==league.id);
  10. //return new NegotiatedContentResult<T>(HttpStatusCode.Conflict, value, this);
  11. Response.StatusCode = StatusCodes.Status409Conflict;
  12. // return BadRequest("duplicate");
  13. return Conflict("duplicate found");
  14. //return new EmptyResult();
  15.  
  16. }
  17. var playerBindWithLeague = new PlayersWithLeagues(getIdFromToken(),league.id);
  18. var initialLeagueStatus = new LeagueState(league.id,"invitation",playerBindWithLeague.PlayerId);
  19. context.LeaguesStates.Add(initialLeagueStatus);
  20. context.PlayersWithLeaguesList.Add(playerBindWithLeague);
  21. context.Leagues.Add(league);
  22. context.SaveChanges();
  23. return Created("Created "+playerBindWithLeague.id.ToString(),league);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement