Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpPost]
- public IActionResult postValue(League league)
- {
- if(league==null){
- return BadRequest("bad object format was given");
- }
- if(context.Leagues.FirstOrDefault(x => x.id==league.id)!=null)
- {
- //var value = context.Users.FirstOrDefault(x => x.id==league.id);
- //return new NegotiatedContentResult<T>(HttpStatusCode.Conflict, value, this);
- Response.StatusCode = StatusCodes.Status409Conflict;
- // return BadRequest("duplicate");
- return Conflict("duplicate found");
- //return new EmptyResult();
- }
- var playerBindWithLeague = new PlayersWithLeagues(getIdFromToken(),league.id);
- var initialLeagueStatus = new LeagueState(league.id,"invitation",playerBindWithLeague.PlayerId);
- context.LeaguesStates.Add(initialLeagueStatus);
- context.PlayersWithLeaguesList.Add(playerBindWithLeague);
- context.Leagues.Add(league);
- context.SaveChanges();
- return Created("Created "+playerBindWithLeague.id.ToString(),league);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement