public VisitDetail GetVisitByID(int visitID)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Visits.FirstOrDefault(visit => visit.VisitID == visitID && visit.OwnerID == _userID);

                if (entity != null)
                {
                    VisitorService visitorService = new VisitorService(_userID, _userIsAdmin);
                    GameService    gameService    = new GameService(_userID, _userIsAdmin);

                    return(new VisitDetail
                    {
                        VisitID = entity.VisitID,
                        GotPin = entity.GotPin,
                        TookPhoto = entity.TookPhoto,
                        Game = gameService.GetGameByID(entity.GameID),
                        Visitor = visitorService.GetVisitorByID(entity.VisitorID)
                    });
                }
                else
                {
                    return(null);
                }
            }
        }
        public IEnumerable <VisitListItem> GetAllVisits()
        {
            using (var ctx = new ApplicationDbContext())
            {
                VisitorService visitorService = new VisitorService(_userID, _userIsAdmin);
                GameService    gameService    = new GameService(_userID, _userIsAdmin);

                var visits =
                    ctx.Visits
                    .Where(visit => visit.OwnerID == _userID)
                    .Select(
                        entity =>
                        new VisitListItem
                {
                    VisitID   = entity.VisitID,
                    GotPin    = entity.GotPin,
                    TookPhoto = entity.TookPhoto,
                    VisitorID = entity.VisitorID,
                    GameID    = entity.GameID
                }
                        ).ToArray();

                foreach (var visit in visits)
                {
                    visit.Visitor = visitorService.GetVisitorByID(visit.VisitorID);
                    visit.Game    = gameService.GetGameByID(visit.GameID);
                }

                var orderedVisits = visits.OrderBy(visit => visit.Game.DateOfGame).ToArray();

                return(orderedVisits);
            }
        }