示例#1
0
        // Afficher les informations de l'evenement concerné
        public async void EventPinTapped(object sender, TappedRoutedEventArgs e)
        {
            Image    image    = e.OriginalSource as Image;
            int      eventId  = Convert.ToInt32(image.Name);
            EventGet eventGet = await this._apiService.GetEventByIdAsync(eventId);

            Geopoint position = new Geopoint(new BasicGeoposition()
            {
                Latitude  = eventGet.Address.Latitude,
                Longitude = eventGet.Address.Longitude
            });

            MapLocationFinderResult finderResult = await MapLocationFinder.FindLocationsAtAsync(position);

            string address = string.Empty;

            if (finderResult.Status == MapLocationFinderStatus.Success)
            {
                var selectedLocation = finderResult.Locations.First();
                address = String.Format("{0} {1} ; {2} ", selectedLocation.Address.StreetNumber, selectedLocation.Address.Street,
                                        selectedLocation.Address.Town);
            }
            if (this._popup != null)
            {
                this._popup.IsOpen = false;
            }
            this._popup        = this.GeneratePopup(eventGet, address);
            this._popup.IsOpen = true;
        }
示例#2
0
        private void DisplayEvent(EventGet eventGet)
        {
            Geopoint eventPosition = new Geopoint(new BasicGeoposition()
            {
                Latitude  = eventGet.Address.Latitude,
                Longitude = eventGet.Address.Longitude
            });

            this._mapService.DisplayEvent(Map, eventPosition, eventGet.Id, EventPinTapped);
        }
示例#3
0
        /// <summary>
        /// Permet de mettre à jour un évenement
        /// </summary>
        /// <param name="eventPost"></param>
        /// <param name="eventId"></param>
        /// <returns>Evenement mis a jour</returns>
        public async Task <EventGet> UpdateEventAsync(EventPost eventPost, int eventId)
        {
            EventGet result = null;

            result = await this.SafeRequest(async() =>
            {
                string response = await this._cob.UpdateEventAsync(eventPost, eventId);
                result          = JsonConvert.DeserializeObject <EventGet>(response);
                return(result);
            });

            return(result);
        }
示例#4
0
        /// <summary>
        /// Permet de récupérer un évenement en fonction de son id
        /// </summary>
        /// <param name="eventId"></param>
        /// <returns>Evenement</returns>
        public async Task <EventGet> GetEventByIdAsync(int eventId)
        {
            EventGet result = null;

            result = await this.SafeRequest(async() =>
            {
                string response = await this._cob.GetEventByIdAsync(eventId);
                result          = JsonConvert.DeserializeObject <EventGet>(response);
                return(result);
            });

            return(result);
        }
示例#5
0
        private Popup GeneratePopup(EventGet eventGet, string addressTxt)
        {
            Popup      pop   = new Popup();
            StackPanel sp    = new StackPanel();
            TextBlock  title = new TextBlock()
            {
                Text         = "Nom de l'évènement : " + eventGet.Name,
                FontSize     = 20,
                TextWrapping = TextWrapping.Wrap,
                Margin       = new Thickness(20, 10, 20, 0)
            };

            // Récupérer directement le champ adresse

            TextBlock address = new TextBlock()
            {
                Text         = "Adresse : " + addressTxt, // TODO : implémenter
                FontSize     = 20,
                TextWrapping = TextWrapping.Wrap,
                Margin       = new Thickness(20, 10, 20, 0)
            };

            // On devrait recevoir dt(utc)...
            // dt = dt(utc) + dtnow - dtnow(utc)
            TimeSpan offset   = DateTime.Now.Subtract(DateTime.UtcNow);
            DateTime realDate = eventGet.Date.Add(offset);

            TextBlock date = new TextBlock()
            {
                Text         = "Date : " + realDate.ToString("d/M/yyyy h:mm"),
                FontSize     = 20,
                TextWrapping = TextWrapping.Wrap,
                Margin       = new Thickness(20, 10, 20, 0)
            };

            sp.Children.Add(title);
            sp.Children.Add(address);
            sp.Children.Add(date);
            sp.Margin     = new Thickness(0, 4 * MainGrid.ActualHeight / 5, 0, 0);
            sp.Height     = 2 * MainGrid.ActualHeight / 5;
            sp.Width      = Frame.ActualWidth;
            sp.Background = new SolidColorBrush(Colors.Black);

            pop.Child = sp;

            return(pop);
        }
示例#6
0
        /// <summary>
        /// Invoqué lorsque cette page est sur le point d'être affichée dans un frame.
        /// </summary>
        /// <param name="e">Données d’événement décrivant la manière dont l’utilisateur a accédé à cette page.
        /// Ce paramètre est généralement utilisé pour configurer la page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            // TODO: préparer la page pour affichage ici.

            // TODO: si votre application comporte plusieurs pages, assurez-vous que vous
            // gérez le bouton Retour physique en vous inscrivant à l’événement
            // Windows.Phone.UI.Input.HardwareButtons.BackPressed.
            // Si vous utilisez le NavigationHelper fourni par certains modèles,
            // cet événement est géré automatiquement.

            this._mapService.StartFollowUser(Map);
            await this._mapService.CenterMapOnUserPositionAsync(Map);

            await this.DisplayEvents();

            if (e.Parameter != null)
            {
                if (e.Parameter.GetType() == typeof(LoginModel))
                {
                    LoginModel loginModel = e.Parameter as LoginModel;
                    if (loginModel.Type == TypeEnum.Login)
                    {
                        try
                        {
                            await this.Login(loginModel);

                            // pas le bon bouton?
                            CommandBar.SecondaryCommands.RemoveAt(0);
                            this.AddDecoButton();
                        }
                        catch (Exception ex)
                        {
                            this.GenerateMessageDialog("Erreur lors de la connexion, vérifiez vos identifiants de connexion.");
                        }
                    }
                    else
                    {
                        try
                        {
                            User user = await this._apiService.RegisterAsync(loginModel.Login, loginModel.Pass, loginModel.Mail);

                            await this.Login(loginModel);

                            CommandBar.SecondaryCommands.RemoveAt(0);
                            this.AddDecoButton();
                        }
                        catch (Exception ex)
                        {
                            this.GenerateMessageDialog("Erreur lors de l'enregistrement.");
                        }
                    }
                }
                else if (e.Parameter.GetType() == typeof(EventModel))
                {
                    try
                    {
                        EventModel eventModel = e.Parameter as EventModel;

                        // timestamp = dt(utc) - dt(1970) + dt - dt
                        // timestamp = dt - dt(1970) + dt(utc) - dt et dt(utc) - dt = dtnow(utc) - dtnow
                        int offset    = (int)DateTime.UtcNow.Subtract(DateTime.Now).TotalSeconds;
                        int timestamp = (int)eventModel.Date.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds + offset;

                        string address = string.Format("{0} {1}", eventModel.Address, eventModel.City);

                        GeolocByAddress geoloc = await this._apiService.GetGeolocAsync(address);

                        EventPost eventPost = new EventPost()
                        {
                            Name      = eventModel.Name,
                            Date      = timestamp,
                            Latitude  = geoloc.Latitude,
                            Longitude = geoloc.Longitude,
                            Address   = eventModel.Address,
                            City      = eventModel.City
                        };
                        EventGet eventGet = await this._apiService.PostEventAsync(eventPost);

                        this.DisplayEvent(eventGet);
                        this._eventList.Add(eventGet);
                    }
                    catch (Exception ex)
                    {
                        this.GenerateMessageDialog("Erreur lors de l'envoi de l'évènement.");
                    }
                }
            }
        }
        //Method that combines Game and practice into one
        private List <EventGet> CalendarGet()
        {
            //Set variables to populate list to store in List<Events>
            List <Practice> getPractice = new List <Practice>();
            List <Game>     getGames    = new List <Game>();
            //create a team bll to get team names



            List <Team> getTeam = team.GetTeams();
            var         users   = Session["Users"] as Users;

            //populate lists
            getPractice = practiceBLL.GetPractice().FindAll(m => m.TeamID == users.TeamID);
            getGames    = gameBLL.GetGames();
            //Add the Games to the list that matches the login users team id
            List <Game> MyTeamGames = new List <Game>();

            MyTeamGames = getGames.FindAll(m => m.HomeTeam == users.TeamID).ToList();

            List <Game> MyAwayGames = getGames.FindAll(m => m.AwayTeam == users.TeamID).ToList();
            //Add practice to the list that matches the Login Users team ID
            //Create Event List
            List <EventGet> addEvents = new List <EventGet>();

            foreach (Practice practice in getPractice)
            {
                //populate an event object for each practice from the database to add to full calendar
                EventGet events     = new EventGet();
                int      practiceId = 001;
                events.EventID     = practiceId;
                events.Title       = "Practice";
                events.Description = practice.PracticeType;
                events.Start       = practice.StartTime;
                events.End         = practice.EndTime;
                //events.StatusColor = System.Drawing.Color.Green;
                //events.BackgroundColor = System.Drawing.Color.Aqua;
                addEvents.Add(events);
                practiceId++;
            }
            foreach (Game games in MyTeamGames)
            {
                //Get Team Name For Home and Away
                Team teamHome = getTeam.Find(m => m.TeamID == games.HomeTeam);
                Team teamAway = getTeam.Find(m => m.TeamID == games.AwayTeam);

                //populate the event object for Each Home Game
                EventGet events = new EventGet();
                int      gameId = 100;
                events.EventID     = gameId;
                events.Title       = teamHome.TeamName + " " + "vs" + " " + teamAway.TeamName;;
                events.Description = teamHome.TeamName + " Score:" + games.HomeTeamScore.ToString() + " " + teamAway.TeamName + " Score:" + games.AwayTeamScore.ToString();
                events.Start       = games.StartTime;
                events.End         = games.EndTime;
                //events.StatusColor = System.Drawing.Color.Orange;
                //events.BackgroundColor = System.Drawing.Color.Blue;
                addEvents.Add(events);
                gameId++;
            }
            foreach (Game games in MyAwayGames)
            {
                //Get Team Name For Home and Away
                Team teamHome = getTeam.Find(m => m.TeamID == games.HomeTeam);
                Team teamAway = getTeam.Find(m => m.TeamID == games.AwayTeam);

                //populate the event object for Each Away Game
                EventGet events = new EventGet();
                int      gameId = 01;
                events.EventID     = gameId;
                events.Title       = teamHome.TeamName + " " + "vs" + " " + teamAway.TeamName;;
                events.Description = teamHome.TeamName + " Score:" + games.HomeTeamScore.ToString() + " " + teamAway.TeamName + " Score:" + games.AwayTeamScore.ToString();
                events.Start       = games.StartTime;
                events.End         = games.EndTime;
                //events.StatusColor = System.Drawing.Color.Black;
                //events.BackgroundColor = System.Drawing.Color.Gold;
                addEvents.Add(events);
                gameId++;
            }
            return(addEvents);
        }