Exemplo n.º 1
0
 public static Game ToGame(this GameDto gameDto)
 {
     if (!MongoIdValidator.Check(gameDto.id))
     {
         gameDto.id = ObjectId.Empty.ToString();
     }
     return(new Game
     {
         Id = new ObjectId(gameDto.id),
         Title = gameDto.title,
         Genre = gameDto.genre
     });
 }
Exemplo n.º 2
0
 public HttpResponseMessage<GameDto> Put(string id, GameDto game)
 {
     if (!CheckIdAndExists(id)) throw new HttpResponseException(HttpStatusCode.NotFound);
     var updated = _gamesService.Update(id, game.ToGame());
     return new HttpResponseMessage<GameDto>(updated.ToDto(), HttpStatusCode.OK);
 }
Exemplo n.º 3
0
 public HttpResponseMessage<GameDto> Post(GameDto game)
 {
     var created = _gamesService.Create(game.ToGame());
     if (created == null) throw new HttpResponseException(HttpStatusCode.BadRequest);
     return new HttpResponseMessage<GameDto>(created.ToDto(), HttpStatusCode.Created);
 }