Ejemplo n.º 1
0
        protected override IActionResult GetRequest()
        {
            Date          = DateTime.Today;
            AllPassengers = _carpoolInterface.GetPassengersAdmin("").Result;
            AllCarpools   = _carpoolInterface.GetAllCarpools(Date).Result;
            List <System.Security.Claims.Claim> listofClaims = User.Claims.ToList();
            User LoggedInUser = _userInterface.GetUser(Guid.Parse(listofClaims[0].Value)).Result;

            foreach (Carpool carpool in AllCarpools.Values)
            {
                if (!AllUsersCarpools.ContainsKey(carpool.Driver.Id))
                {
                    AllUsersCarpools.Add(carpool.Driver.Id, new Statistic()
                    {
                        Carpool = carpool, NumberOfTimes = 1
                    });
                }
                else
                {
                    AllUsersCarpools[carpool.Driver.Id].NumberOfTimes++;
                }
            }

            foreach (Passenger pas in AllPassengers)
            {
                if (!AllUsersPassengers.ContainsKey(pas.User.Id))
                {
                    AllUsersPassengers.Add(pas.User.Id, new Statistic()
                    {
                        Passenger = pas, NumberOfTimes = 1
                    });
                }
                else
                {
                    AllUsersPassengers[pas.User.Id].NumberOfTimes++;
                }
            }

            if (LoggedInUser.UserType != UserType.Admin)
            {
                RedirectToPage("/Index");
            }

            return(Page());
        }
Ejemplo n.º 2
0
        public IActionResult OnPost()
        {
            if (!String.IsNullOrWhiteSpace(Search))
            {
                AllCarpools   = _carpoolInterface.GetAllCarpoolsAdmin(Date, Search.ToLower()).Result;
                AllPassengers = _carpoolInterface.GetPassengersAdmin(Search).Result;

                foreach (Carpool carpool in AllCarpools.Values)
                {
                    if (!AllUsersCarpools.ContainsKey(carpool.Driver.Id))
                    {
                        AllUsersCarpools.Add(carpool.Driver.Id, new Statistic()
                        {
                            Carpool = carpool, NumberOfTimes = 1
                        });
                    }
                    else
                    {
                        AllUsersCarpools[carpool.Driver.Id].NumberOfTimes++;
                    }
                }

                foreach (Passenger pas in AllPassengers)
                {
                    if (!AllUsersPassengers.ContainsKey(pas.User.Id))
                    {
                        AllUsersPassengers.Add(pas.User.Id, new Statistic()
                        {
                            Passenger = pas, NumberOfTimes = 1
                        });
                    }
                    else
                    {
                        AllUsersPassengers[pas.User.Id].NumberOfTimes++;
                    }
                }
            }
            else
            {
                AllCarpools   = new Dictionary <int, Carpool>();
                AllPassengers = new List <Passenger>();
            }
            return(Page());
        }