daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top