public async Task <string> CreateRound([FromBody] RoundServiceCreateRoundViewModel viewModel) { viewModel.Deck = (new DeckLogic()).Stringify(); var result = await _roundService.CreateRound(viewModel); return(result); }
public async Task <string> CreateRound(RoundServiceCreateRoundViewModel viewModel) { try { var entity = DataMapper.Map(viewModel); if (entity.GameId != Guid.Empty) { var result = await _roundRepository.Add(entity); return(result); } } catch (Exception ex) { Logger.WriteLogToFile(ex.Message, "RoundService", "CreateRound"); } return("Game does not exist!"); }
public static Round Map(RoundServiceCreateRoundViewModel viewModel) { if (Guid.TryParse(viewModel.GameId, out Guid gameId)) { var entity = new Round() { Id = Guid.Empty, GameId = gameId, RoundNumber = viewModel.RoundNumber, Deck = viewModel.Deck }; return(entity); } return(new Round { Id = Guid.Empty, GameId = Guid.Empty }); }