public ActionResult AddGame([FromBody] PostGameRequest game)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     return(Ok($"Added Game {game.Title} under {game.Platform} platform"));
 }
 //when it calls the method it creates an instance of game
 // It deserialize the game. then it runs the validation attributes
 // and uses the result to produce ModelState
 public ActionResult AddGame([FromBody] PostGameRequest game)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     else
     {
         return(Ok($"Adding {game.Title} for {game.Platform} for {game.Price:c}"));
     }
 }
Esempio n. 3
0
 public ActionResult AddGame([FromBody] PostGameRequest game)
 {
     return(Ok($"adding {game.Title} for {game.Platform}"));
 }