示例#1
0
 public async System.Threading.Tasks.Task <OperationResult <Game> > GetGames(int pageSize, int pageNumber, bool descending)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Game> >(() =>
     {
         OperationResult <Game> result = new OperationResult <Game>();
         try
         {
             if (IsInCompany())
             {
                 result.Count = GamesRepository.Count("CompanyId = @CompanyId", new { CompanyId = CurrentUser.CompanyId.Value });
                 if (result.Count > 0)
                 {
                     result.MultipleResult = GamesRepository.Search("CompanyId = @CompanyId",
                                                                    new { PageSize = pageSize, PageNumber = pageNumber, CompanyId = CurrentUser.CompanyId.Value }, descending);
                 }
                 result.Result = true;
             }
             else
             {
                 result.Count = GamesRepository.Count("CreatorId = @CreatorId", new { CreatorId = CurrentUser.Id });
                 if (result.Count > 0)
                 {
                     result.MultipleResult = GamesRepository.Search("CreatorId = @CreatorId",
                                                                    new { PageSize = pageSize, PageNumber = pageNumber, CreatorId = CurrentUser.Id }, descending);
                 }
                 result.Result = true;
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
示例#2
0
 public async System.Threading.Tasks.Task <OperationResult <MyGameReponseSingle> > GetMyGames(int pageSize, int pageNumber, bool descending)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <MyGameReponseSingle> >(() =>
     {
         OperationResult <MyGameReponseSingle> result = new OperationResult <MyGameReponseSingle>();
         try
         {
             result.Count = GamesRepository.Count("CreatorId = @CreatorId", new { CreatorId = CurrentUser.Id });
             if (result.Count > 0)
             {
                 List <MyGameReponseSingle> response = new List <MyGameReponseSingle>();
                 var games = GamesRepository.Search("CreatorId = @CreatorId", new { PageSize = pageSize, PageNumber = pageNumber, CreatorId = CurrentUser.Id }, descending);
                 foreach (var game in games)
                 {
                     MyGameReponseSingle single = new MyGameReponseSingle();
                     single.Game = game;
                     single.Playground = PlaygroundsRepository.Read(game.Playground);
                     single.GameType = GameTypesRepository.Read(game.GameType);
                     response.Add(single);
                 }
                 result.MultipleResult = response;
             }
             result.Result = true;
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
示例#3
0
 public async System.Threading.Tasks.Task <OperationResult <Game> > GetGames(DateTime date)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Game> >(() =>
     {
         OperationResult <Game> result = new OperationResult <Game>();
         try
         {
             DateTime startDate = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
             DateTime endDate = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59);
             if (IsInCompany())
             {
                 result.Count = GamesRepository.Count("CompanyId = @CompanyId AND BeginDate BETWEEN @StartDate AND @EndDate",
                                                      new { CompanyId = CurrentUser.CompanyId, StartDate = startDate, EndDate = endDate });
                 if (result.Count > 0)
                 {
                     result.MultipleResult = GamesRepository.Search("CompanyId = @CompanyId AND BeginDate BETWEEN @StartDate AND @EndDate",
                                                                    new { PageSize = 100, PageNumber = 1, CompanyId = CurrentUser.CompanyId, StartDate = startDate, EndDate = endDate });
                 }
                 result.Result = true;
             }
             else
             {
                 result.Count = GamesRepository.Count("CreatorId = @CreatorId AND BeginDate BETWEEN @StartDate AND @EndDate",
                                                      new { CreatorId = CurrentUser.Id, StartDate = startDate, EndDate = endDate });
                 if (result.Count > 0)
                 {
                     result.MultipleResult = GamesRepository.Search("CreatorId = @CreatorId AND BeginDate BETWEEN @StartDate AND @EndDate",
                                                                    new { PageSize = 100, PageNumber = 1, CreatorId = CurrentUser.Id, StartDate = startDate, EndDate = endDate });
                 }
                 result.Result = true;
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
示例#4
0
        public async System.Threading.Tasks.Task <OperationResult <MyGameReponseSingle> > GetMyGames(DateTime date, int pageSize, int pageNumber, bool descending)
        {
            return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <MyGameReponseSingle> >(() =>
            {
                OperationResult <MyGameReponseSingle> result = new OperationResult <MyGameReponseSingle>();
                try
                {
                    DateTime startDate = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
                    DateTime endDate = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59);

                    result.Count = GamesRepository.Count("CreatorId = @CreatorId AND BeginDate BETWEEN @StartDate AND @EndDate",
                                                         new { CreatorId = CurrentUser.Id, StartDate = startDate, EndDate = endDate });
                    if (result.Count > 0)
                    {
                        List <MyGameReponseSingle> response = new List <MyGameReponseSingle>();
                        var games = GamesRepository.Search("CreatorId = @CreatorId AND BeginDate BETWEEN @StartDate AND @EndDate",
                                                           new { PageSize = pageSize, PageNumber = pageNumber, CreatorId = CurrentUser.Id, StartDate = startDate, EndDate = endDate });
                        foreach (var game in games)
                        {
                            MyGameReponseSingle single = new MyGameReponseSingle();
                            single.Game = game;
                            single.Playground = PlaygroundsRepository.Read(game.Playground);
                            single.GameType = GameTypesRepository.Read(game.GameType);
                            response.Add(single);
                        }
                        result.MultipleResult = response;
                    }
                    result.Result = true;
                }
                catch (Exception ex)
                {
                    LoggingService.Log(ex);
                }
                return result;
            }));
        }