Esempio n. 1
0
        public ActionResult GetApostadores(JqGridRequest request)
        {
            //int equipoId = ViewBag.ApuestaId;
            int totalRecords = 0;
            List<Apostador> apuestas = repository.dal_apostador.GetApostadores(); ;
            totalRecords = apuestas.Count();

            //Prepare JqGridData instance
            JqGridResponse response = new JqGridResponse()
            {
                //Total pages count
                TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
                //Page number
                PageIndex = request.PageIndex,
                //Total records count
                TotalRecordsCount = totalRecords
            };

            foreach (Apostador apuesta in apuestas)
            {
                response.Records.Add(new JqGridRecord(Convert.ToString(apuesta.ApostadorId), new List<object>()
                {
                   apuesta.ApostadorId,
                   apuesta.Nombre,
                   apuesta.Correo,
                   apuesta.Puntaje
                }));
            }

            //Return data as json
            return new JqGridJsonResult() { Data = response };
        }
Esempio n. 2
0
        public JqGridJsonResult GetUsersGridModel(JqGridRequest request)
        {
            var enumerable = this.Manager.FindAll(new UserAll(true));

            var users = new List<UserEntity>(enumerable);

            var totalRecordsCount = users.Count();

            var list = (from u in users
                        select
                            new JqGridRecord<UserGridModel>(
                                u.Id.ToString(CultureInfo.InvariantCulture), 
                                new UserGridModel
                                {
                                    Id = u.Id,
                                    Name = u.Name,
                                    Email = u.Email,
                                    Login = u.UserPasswordCredential != null ? u.UserPasswordCredential.Login : string.Empty,
                                })).ToList();

            var response = new JqGridResponse
                {
                    TotalPagesCount = (int)Math.Ceiling(totalRecordsCount / (float)request.RecordsCount),
                    PageIndex = request.PageIndex,
                    TotalRecordsCount = totalRecordsCount,
                };

            response.Records.AddRange(list);

            return new JqGridJsonResult { Data = response };
        }
        public ActionResult NameSpaces(JqGridRequest request)
        {
            using (var db = new ContentRepository())
            {
                var nameSpaceQry = from n in db.NameSpaces orderby n.Id select n;

                var totalRecs = db.NameSpaces.Count();
                var response = new JqGridResponse()
                                   {
                                       TotalPagesCount =
                                           (int) Math.Ceiling((float) totalRecs/(float) request.RecordsCount),
                                       PageIndex = request.PageIndex,
                                       TotalRecordsCount = totalRecs
                                   };

                var nameSpaces = nameSpaceQry
                    .Skip(request.PageIndex*request.RecordsCount)
                    .Take((request.PagesCount.HasValue ? request.PagesCount.Value : 1)*request.RecordsCount).ToList();

                var jqGridRecords = from n in nameSpaces
                        select new JqGridRecord<NameSpaceGridModel>(
                            n.Id.ToString(),
                            new NameSpaceGridModel(n));

                response.Records.AddRange(jqGridRecords);

                return new JqGridJsonResult() { Data = response };
            }
        }
Esempio n. 4
0
        public ActionResult Search(JqGridRequest request, String marketSearchBoxString)
        {
            int totalRecordsCount = CoinManager.GetCount(new MarketSearchBoxModel(marketSearchBoxString));

            JqGridResponse response = new JqGridResponse()
            {
                TotalPagesCount = (int)Math.Ceiling((float)totalRecordsCount / (float)request.RecordsCount),
                PageIndex = request.PageIndex,
                TotalRecordsCount = totalRecordsCount
            };

            IList<CoinViewModel> coins = new List<CoinViewModel>();
            foreach (var coin in CoinManager.GetCoinsByMarketSearch(
                new MarketSearchBoxModel(marketSearchBoxString),
                String.Format("{0} {1}", request.SortingName, request.SortingOrder), request.PageIndex))
            {
                response.Records.Add(new JqGridRecord<CoinViewModel>(
                    Convert.ToString(coin.Id),
                    new CoinViewModel(coin)
                ));
            }

            ViewBag.MarketSearchBoxString = marketSearchBoxString;
            return new JqGridJsonResult() { Data = response };
        }
Esempio n. 5
0
        public ActionResult Employees(JqGridRequest request)
        {
            using (var proxy = new TimeCardServiceClient())
            {
                var employees = proxy.SearchEmployees(null, null, null, false);

                var response = new JqGridResponse();

                response.Records.AddRange(employees.Select(e => new JqGridRecord<EmployeeModel>(Convert.ToString(e.Id), e.ToModel())));

                return new JqGridJsonResult
                           {
                               Data = response
                           };
            }
        }
Esempio n. 6
0
        public ActionResult Partidos(JqGridRequest request)
        {
            _logger.Info("START  Partidos");
            JqGridResponse response;
            try
            {
                int totalRecords = 0;

                List<PartidosView> partidos = repository.dal_partido.GetPartidosView(0);
                totalRecords = partidos.Count();
                //Prepare JqGridData instance
                response = new JqGridResponse()
                {
                    //Total pages count
                    TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
                    //Page number
                    PageIndex = request.PageIndex,
                    //Total records count
                    TotalRecordsCount = totalRecords
                };

                foreach (PartidosView partido in partidos)
                {
                    response.Records.Add(new JqGridRecord(Convert.ToString(partido.PartidoId), new List<object>()
                {
                    partido.PartidoId,
                    partido.EquipoIdLocal,
                    partido.EquipoDescLocal,
                    partido.GolesLocal,
                    partido.Resultado,
                    partido.EquipoIdVisita,
                    partido.GolesVisita,
                    partido.EquipoDescVisita
                }));
                }

            }
            catch (Exception ex)
            {
                _logger.Error("Error : ", ex);
                throw;
            }
            finally
            {

            }
            //Return data as json
            return new JqGridJsonResult() { Data = response };
        }
Esempio n. 7
0
        public ActionResult GetPartidosUpdate(JqGridRequest request)
        {
            //int equipoId = ViewBag.ApuestaId;
            int totalRecords = 0;
            List<PartidoLog> partidos = repository.dal_partido_log.GetPartidos();
            totalRecords = partidos.Count();

            //Prepare JqGridData instance
            JqGridResponse response = new JqGridResponse()
            {
                //Total pages count
                TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
                //Page number
                PageIndex = request.PageIndex,
                //Total records count
                TotalRecordsCount = totalRecords
            };

            foreach (PartidoLog partido in partidos)
            {
                response.Records.Add(new JqGridRecord(Convert.ToString(partido.Id), new List<object>()
                {
                   partido.Id,
                   partido.PartidoId,
                   partido.UserId,
                   partido.UpdateDate.ToString("yy/MM/dd hh:mm:ss"),
                   partido.Partido.EquipoIdLocal,
                   partido.Partido.EquipoDescLocal,
                   partido.Partido.GolesLocal,
                   partido.Partido.Resultado,
                   partido.Partido.EquipoIdVisita,
                   partido.Partido.EquipoDescVisita,
                   partido.Partido.GolesVisita
                }));
            }

            //Return data as json
            return new JqGridJsonResult() { Data = response };
        }
Esempio n. 8
0
        public ActionResult GetEquipos(JqGridRequest request)
        {
            //int equipoId = ViewBag.ApuestaId;
            int totalRecords = 0;
            List<Equipo> equipos = repository.dal_equipo.GetEquipos(); ;
            totalRecords = equipos.Count();

            //Prepare JqGridData instance
            JqGridResponse response = new JqGridResponse()
            {
                //Total pages count
                TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
                //Page number
                PageIndex = request.PageIndex,
                //Total records count
                TotalRecordsCount = totalRecords
            };

            foreach (Equipo equipo in equipos)
            {
                response.Records.Add(new JqGridRecord(Convert.ToString(equipo.Equipo_ID), new List<object>()
                {
                   equipo.Equipo_ID,
                   equipo.Grupo,
                   equipo.Equipo_desc,
                   equipo.Ptos,
                   equipo.PJ,
                   equipo.PG,
                   equipo.PE,
                   equipo.PP,
                   equipo.GF,
                   equipo.GC,
                   equipo.DG,
                }));
            }

            //Return data as json
            return new JqGridJsonResult() { Data = response };
        }
        public ActionResult GridData(JqGridRequest request, int id, int GrandChampionId)
        {
            IQueryable<Competitor> competitors = db.Competitors.Where(m => m.TournamentId == id && m.GrandChampionId == GrandChampionId).OrderByDescending(m => m.CompetitorDivisions.Sum(cd => cd.Result));

            int totalRecords = competitors.Count();

            //Prepare JqGridData instance
            JqGridResponse response = new JqGridResponse
            {
                //Total pages count
                TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
                //Page number
                PageIndex = request.PageIndex,
                //Total records count
                TotalRecordsCount = totalRecords
            };

            //Table with rows data
            foreach (Competitor competitor in competitors.Skip(request.PageIndex * request.RecordsCount).Take(request.PagesCount.HasValue ? request.PagesCount.Value : 1 * request.RecordsCount))
            {
                string GoldCount = competitor.CompetitorDivisions.Count(m => m.Result == 5).ToString();
                string SilverCount = competitor.CompetitorDivisions.Count(m => m.Result == 3).ToString();
                string BronzeCount = competitor.CompetitorDivisions.Count(m => m.Result == 2).ToString();
                string CopperCount = competitor.CompetitorDivisions.Count(m => m.Result == 1).ToString();
                string TotalPoints = competitor.CompetitorDivisions.Sum(m => m.Result).ToString();
                response.Records.Add(new JqGridRecord(Convert.ToString(competitor.CompetitorId), new List<object>()
                {
                    competitor.CompetitorId,
                    competitor.Student.FirstName,
                    competitor.Student.LastName,
                    competitor.Student.School.SchoolName,
                    GoldCount,
                    SilverCount,
                    BronzeCount,
                    CopperCount,
                    TotalPoints
                }));
            }

            //Return data as json
            return new JqGridJsonResult() { Data = response };
        }
        public ActionResult GridData(JqGridRequest request, int id)
        {
            IQueryable<TournamentDivision> tournamentDivisions = db.TournamentDivisions.Where(m => m.TournamentId == id);

            if (request.Searching)
            {
                foreach (JqGridRequestSearchingFilter searchingFilter in request.SearchingFilters.Filters)
                {
                    int searchValue;

                    if (Int32.TryParse(searchingFilter.SearchingValue, out searchValue))
                    {
                        if (searchingFilter.SearchingName.Contains(WKSADBConstants.RankId))
                        {
                            tournamentDivisions = tournamentDivisions.Where(m => m.Division.RankId == searchValue);
                        }
                        if (searchingFilter.SearchingName.Contains(WKSADBConstants.DivisionTypeId))
                        {
                            tournamentDivisions = tournamentDivisions.Where(m => m.Division.DivisionTypeId == searchValue);
                        }
                        if (searchingFilter.SearchingName.Contains(WKSADBConstants.AgeGroupId))
                        {
                            tournamentDivisions = tournamentDivisions.Where(m => m.Division.AgeGroupId == searchValue);
                        }
                    }
                }
            }

            int totalRecords = tournamentDivisions.Count();

            //Prepare JqGridData instance
            JqGridResponse response = new JqGridResponse()
            {
                //Total pages count
                TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
                //Page number
                PageIndex = request.PageIndex,
                //Total records count
                TotalRecordsCount = totalRecords
            };

            //Table with rows data
            foreach (TournamentDivision tournamentDivision in tournamentDivisions.OrderBy(request.SortingName + " " + request.SortingOrder.ToString()).Skip(request.PageIndex * request.RecordsCount).Take(request.PagesCount.HasValue ? request.PagesCount.Value : 1 * request.RecordsCount))
            {
                response.Records.Add(new JqGridRecord(Convert.ToString(tournamentDivision.DivisionId), new List<object>()
                {
                    tournamentDivision.DivisionId,
                    tournamentDivision.Division.DivisionName,
                    tournamentDivision.Division.Rank.Description,
                    tournamentDivision.Division.DivisionType.Description,
                    tournamentDivision.Division.AgeGroup.Description
                }));
            }

            //Return data as json
            return new JqGridJsonResult() { Data = response };
        }
        public ActionResult Products(JqGridRequest request, TaskObjects viewModel)
        {
            //Service1Client obj = new Service1Client();

            JqGridResponse response = new JqGridResponse();
            List<TaskObjects> listobj = new List<TaskObjects>();
            Task dal = new Task();
            var m = dal.LsitTask();
            //var m = obj.display();
            listobj = m.ToList();

            foreach (TaskObjects product in listobj)
            {
                response.Records.Add(new JqGridRecord(Convert.ToString(product.TaskId), new List<object>()
                {
                   product.TaskId,
                   product.ProjectName,
                   product.ModuleName,
                   product.ScreenName,

                   product.TaskName,
                   product.EstimateHours,
                   product.Priority,

                   product.Creator,
                   product.Reviewer,
                   product.Assigned,

                   product.StartDate,
                   product.EndDate,

                   product.StartTime,
                   product.EndTime,

                   product.Status,
                   product.Comments,

                }));
            }

            return new JqGridJsonResult() { Data = response };
        }
Esempio n. 12
0
        public ActionResult HomePageGridData(JqGridRequest request)
        {
            IQueryable<School> schools = db.Schools.OrderBy(m => m.SchoolName);

            if (request.Searching)
            {
                foreach (JqGridRequestSearchingFilter searchingFilter in request.SearchingFilters.Filters)
                {
                    // No idea why I have to assign this to a string var first. Doesn't work otherwise!?!
                    string searchText = searchingFilter.SearchingValue;

                    if (searchingFilter.SearchingName.Contains(WKSADBConstants.SchoolCode))
                    {
                        schools = schools.Where(m => m.SchoolCode.Contains(searchText));
                    }
                    else if (searchingFilter.SearchingName.Contains(WKSADBConstants.SchoolName))
                    {
                        schools = schools.Where(m => m.SchoolName.Contains(searchText));
                    }
                    else if (searchingFilter.SearchingName.Contains(WKSADBConstants.InstructorName))
                    {
                        schools = schools.Where(m => m.InstructorName.Contains(searchText));
                    }
                    else
                    {
                        int searchValue;

                        if (Int32.TryParse(searchingFilter.SearchingValue, out searchValue))
                        {
                            if (searchingFilter.SearchingName.Contains(WKSADBConstants.CountryName))
                            {
                                schools = schools.Where(m => m.CountryId == searchValue);
                            }
                        }
                    }
                }
            }

            int totalRecords = schools.Count();

            //Prepare JqGridData instance
            JqGridResponse response = new JqGridResponse()
            {
                //Total pages count
                TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
                //Page number
                PageIndex = request.PageIndex,
                //Total records count
                TotalRecordsCount = totalRecords
            };

            //Table with rows data
            foreach (School school in schools.OrderBy(request.SortingName + " " + request.SortingOrder.ToString()).Skip(request.PageIndex * request.RecordsCount).Take(request.PagesCount.HasValue ? request.PagesCount.Value : 1 * request.RecordsCount))
            {
                response.Records.Add(new JqGridRecord(Convert.ToString(school.SchoolId), new List<object>()
                {
                    school.SchoolId,
                    school.SchoolCode,
                    school.SchoolName,
                    school.Country.CountryName,
                    school.InstructorName
                }));
            }

            //Return data as json
            return new JqGridJsonResult() { Data = response };
        }
Esempio n. 13
0
        public ActionResult GridData(JqGridRequest request, int id)
        {
            IOrderedEnumerable<IGrouping<int, Competitor>> schools = null;

            switch(request.SortingName)
            {
                case "CompetitorCount":
                    if (request.SortingOrder.Equals(JqGridSortingOrders.Desc))
                    {
                        schools = db.Competitors.Where(m => m.TournamentId == id).ToLookup(m => m.Student.SchoolId).OrderBy(m => m.Count());
                    }
                    else
                    {
                        schools = db.Competitors.Where(m => m.TournamentId == id).ToLookup(m => m.Student.SchoolId).OrderByDescending(m => m.Count());
                    }
                    break;
                case "Average":
                    if (request.SortingOrder.Equals(JqGridSortingOrders.Desc))
                    {
                        schools = db.Competitors.Where(m => m.TournamentId == id).ToLookup(m => m.Student.SchoolId).OrderBy(m => m.Sum(c => c.CompetitorDivisions.Sum(cd => cd.Result)) / m.Count());
                    }
                    else
                    {
                        schools = db.Competitors.Where(m => m.TournamentId == id).ToLookup(m => m.Student.SchoolId).OrderByDescending(m => m.Sum(c => c.CompetitorDivisions.Sum(cd => cd.Result)) / m.Count());
                    }
                    break;
                case "TotalPoints":
                    if (request.SortingOrder.Equals(JqGridSortingOrders.Desc))
                    {
                        schools = db.Competitors.Where(m => m.TournamentId == id).ToLookup(m => m.Student.SchoolId).OrderByDescending(m => m.Sum(c => c.CompetitorDivisions.Sum(cd => cd.Result)));
                    }
                    else
                    {
                        schools = db.Competitors.Where(m => m.TournamentId == id).ToLookup(m => m.Student.SchoolId).OrderBy(m => m.Sum(c => c.CompetitorDivisions.Sum(cd => cd.Result)));
                    }
                    break;
            }

            int totalRecords = schools.Count();

            //Prepare JqGridData instance
            JqGridResponse response = new JqGridResponse()
            {
                //Total pages count
                TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
                //Page number
                PageIndex = request.PageIndex,
                //Total records count
                TotalRecordsCount = totalRecords
            };

            //Table with rows data
            foreach (IGrouping<int, Competitor> schoolCompetitors in schools.Skip(request.PageIndex * request.RecordsCount).Take(request.PagesCount.HasValue ? request.PagesCount.Value : 1 * request.RecordsCount))
            {
                School school = schoolCompetitors.First().Student.School;
                int CompetitorCount = schoolCompetitors.Count();
                int? TotalPoints = schoolCompetitors.Sum(s => s.CompetitorDivisions.Sum(cd => cd.Result));
                decimal Average = TotalPoints.HasValue ? TotalPoints.Value / CompetitorCount : 0;

                response.Records.Add(new JqGridRecord(Convert.ToString(school.SchoolId), new List<object>()
                {
                    school.SchoolId,
                    school.SchoolCode,
                    school.SchoolName,
                    school.InstructorName,
                    CompetitorCount.ToString(),
                    Average.ToString("0.#"),
                    TotalPoints.ToString()
                }));
            }

            //Return data as json
            return new JqGridJsonResult() { Data = response };
        }