public async Task Can_Create_New_Game() { var publisherId = _publisherRepository.GetAllAsync().GetAwaiter().GetResult().First().Id; var entity = GamesTestData.SecondGame; var expected = new GameForCreationModel { Name = entity.Name, Description = entity.Description, PlatformTypesId = entity.GamePlatformType.Select(x => x.PlatformTypeId).ToArray(), GenresId = entity.GameGenre.Select(x => x.Genre.Id).ToArray(), PublisherId = publisherId }; var ee = Mapper.Map <GameModel>(expected); var res = await _gameService.SaveSafe(ee); res.Should().BeOfType <Right <Error, GameModel> >(); }
public IActionResult UpdateGame(Guid id, GameForCreationModel game) => _gameService.UpdateSafe(id, Mapper.Map <GameModel>(game)).GetAwaiter().GetResult() .OnSuccess(x => (IActionResult)NoContent()) .OnFailure(_ => BadRequest(), error => error is ArgumentNullError) .OnFailure(error => error.ToObjectResult(), error => error != null) .OnFailure(_ => ModelState.ToObjectResult());
public async Task <IActionResult> CreateGame(GameForCreationModel game) => (await _gameService.SaveSafe(Mapper.Map <GameModel>(game))) .OnSuccess(GetRoute) .OnFailure(_ => BadRequest(), error => error is ArgumentNullError) .OnFailure(error => error.ToObjectResult(), error => error != null) .OnFailure(_ => ModelState.ToObjectResult());