Esempio n. 1
0
        public async Task <string> CreateGame(GameServiceCreateGameViewModel viewModel)
        {
            try
            {
                var result = await _gameRepository.Add(DataMapper.Map(viewModel));

                return(result);
            }
            catch (Exception ex)
            {
                Logger.WriteLogToFile(ex.Message, "GameService", "CreateGame");
            }
            return("error");
        }
Esempio n. 2
0
        public static Game Map(GameServiceCreateGameViewModel viewModel)
        {
            if (DateTime.TryParse(viewModel.Start, out DateTime startTime))
            {
                var entity = new Game()
                {
                    Id    = Guid.Empty,
                    Start = startTime
                };

                return(entity);
            }
            else
            {
                return new Game()
                       {
                           Id    = Guid.Empty,
                           Start = DateTime.Now
                       }
            };
        }
        public async Task <string> CreateGame([FromBody] GameServiceCreateGameViewModel viewModel)
        {
            var result = await _gameService.CreateGame(viewModel);

            return(result);
        }