public async System.Threading.Tasks.Task <OperationResult <MyGameReponseSingle> > CreateMyGame(Game game) { return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <MyGameReponseSingle> >(() => { OperationResult <MyGameReponseSingle> result = new OperationResult <MyGameReponseSingle>(); try { game.CreatorId = CurrentUser.Id; Game newGame = GamesRepository.CreateOrUpdate(game); if (newGame.Id > 0) { newGame.CreatorId = Guid.Empty; MyGameReponseSingle single = new MyGameReponseSingle(); single.Playground = PlaygroundsRepository.Read(game.Playground); single.GameType = GameTypesRepository.Read(game.GameType); single.Game = newGame; single.Orders = EquipmentOrdersRepository.Search("GameId = @GameId", new { PageSize = 1, PageNumber = 200, GameId = game.Id }, true); result.SingleResult = single; result.Result = true; } } catch (Exception ex) { LoggingService.Log(ex); } return result; })); }
public async System.Threading.Tasks.Task <OperationResult <Game> > CreateGame(Game game) { return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Game> >(() => { OperationResult <Game> result = new OperationResult <Game>(); try { if (IsInCompany()) { game.CompanyId = CurrentUser.CompanyId.Value; game.CreatorId = CurrentUser.Id; Game newGame = GamesRepository.CreateOrUpdate(game); if (newGame.Id > 0) { result.SingleResult = newGame; result.Result = true; } } else { game.CreatorId = CurrentUser.Id; Game newGame = GamesRepository.CreateOrUpdate(game); if (newGame.Id > 0) { result.SingleResult = newGame; result.Result = true; } } } catch (Exception ex) { LoggingService.Log(ex); } return result; })); }