Exemplo n.º 1
0
        public ActionResult GetAllEventData(int eventId, string adminToken)
        {
            try
            {
                var managementService = new ManagementService(eventId, adminToken);

                var ratings = managementService.GetEventUserData();
                var comments = managementService.GetEventComments();

                var overallRating = ratings
                    .Where(x => x.Overall != null)
                    .Select(x => x.Overall.Value)
                    .ToList();

                var overallRatingSpread = overallRating.GroupBy(x => x)
                    .Select(x => new { score = x.Key, count = x.Count() });

                double avgoverallRating = (double)overallRating.Sum() / (double)overallRating.Count();

                var refreshmentsRating = ratings
                    .Where(x => x.Refreshments != null)
                    .Select(x => x.Refreshments.Value)
                    .ToList();

                var refreshmentsRatingSpread = refreshmentsRating.GroupBy(x => x)
                    .Select(x => new { score = x.Key, count = x.Count() });

                double avgrefreshmentsRating = (double)refreshmentsRating.Sum() / (double)refreshmentsRating.Count();

                var venueRating = ratings
                    .Where(x => x.Venue != null)
                    .Select(x => x.Venue.Value)
                    .ToList();

                var venueRatingSpread = venueRating.GroupBy(x => x)
                    .Select(x => new { score = x.Key, count = x.Count() });

                double avgvenueRating = (double)venueRating.Sum() / (double)venueRating.Count();

                var hackPerseveranceCount = ratings.Where(x => x.EasterEggP).Count();
                var hackRussianRoulette = ratings.Where(x => x.EasterEggRR).Count();

                var data = new
                {
                    calcRating = new
                    {
                        avgOverallRating = Math.Round(avgoverallRating, 2),
                        avgRefreshmentsRating = Math.Round(avgrefreshmentsRating, 2),
                        avgvenueRating = Math.Round(avgvenueRating, 2),
                        overallRatingSpread = overallRatingSpread,
                        refreshmentsRatingSpread = refreshmentsRatingSpread,
                        venueRatingSpread = venueRatingSpread,
                        hackPerseveranceCount = hackPerseveranceCount,
                        hackRussianRoulette = hackRussianRoulette
                    },
                    comments = comments
                };
                return new JsonNetResult(data);

            }
            catch (Exception)
            {
                throw new Exception("Error");
            }
        }
Exemplo n.º 2
0
        public ActionResult GetEasterEggPeople(int eventId, string adminToken)
        {
            try
            {
                var managementService = new ManagementService(eventId, adminToken);

                var ratings = managementService.GetEventUserData();

                var hackPerseverance = ratings.Where(x => x.EasterEggP)
                    .Select(x=>new {
                      name = x.UserName,
                      token = x.ClientToken
                    }).ToList();
                var hackRussian= ratings.Where(x => x.EasterEggRR)
                   .Select(x => new
                   {
                       name = x.UserName,
                       token = x.ClientToken
                   }).ToList();

                var data = new
                {
                    calcRating = new
                    {
                        hackPerseverance = hackPerseverance,
                        hackRussian = hackRussian
                    }
                };
                return new JsonNetResult(data);
            }
            catch (Exception)
            {

                throw new Exception("Error");
            }
        }