private void SetData(object sender, PropertyChangedEventArgs e)
        {
            if (_socketManager.ServerResponse.RequestTarget == "members")
            {
                Data = JsonConvert.DeserializeObject <ObservableCollection <Member> >(
                    _socketManager.ServerResponse.RequestContent.ToString());
            }

            if (_socketManager.ServerResponse.RequestTarget == "clubs")
            {
                AllClubs = JsonConvert.DeserializeObject <ObservableCollection <Club> >(
                    _socketManager.ServerResponse.RequestContent.ToString());

                Clubs.Clear();
            }

            if (_socketManager.ServerResponse.RequestTarget == "sports")
            {
                AllSports = JsonConvert.DeserializeObject <ObservableCollection <Sport> >(
                    _socketManager.ServerResponse.RequestContent.ToString());

                Sports.Clear();
                foreach (Sport s in AllSports)
                {
                    Sports.Add(s);
                }
            }
        }
        private void ListView_MemberSportsSelection(object sender, SelectionChangedEventArgs e)
        {
            var item = (sender as ListView).SelectedItem as Sport;

            if (item != null)
            {
                Sports.Add(item);
                MemberSports.Remove(item);
                Clubs.Clear();
                foreach (Sport memberSport in MemberSports)
                {
                    foreach (Club clubMemberSport in memberSport.Clubs)
                    {
                        Clubs.Add(clubMemberSport);
                    }
                }

                var memClubs = new List <Club>();
                foreach (Club c in MemberClubs)
                {
                    memClubs.Add(c);
                }

                foreach (Club c in memClubs)
                {
                    foreach (Club club in item.Clubs)
                    {
                        if (club.Id == c.Id)
                        {
                            MemberClubs.Remove(c);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 private void FillSports()
 {
     Sports.Clear();
     foreach (var item in db.Sports.ToList())
     {
         Sports.Add(item);
     }
     SportCount = Sports.Count;
 }
        private async void GetSports()
        {
            var data = await new SportDataService().GetSportsAsync();

            Sports.Clear();
            foreach (var item in data)
            {
                Sports.Add(item);
            }
        }
Esempio n. 5
0
    private void buildSports()
    {
        Model_Sport football = new Model_Sport("Football", SportsResponseCommand);
        Model_Sport golf     = new Model_Sport("Golf", SportsResponseCommand);
        Model_Sport hockey   = new Model_Sport("Hockey", SportsResponseCommand);

        football.IsChecked = true;         // just for test
        Sports.Add(football.Name, football);
        Sports.Add(golf.Name, golf);
        Sports.Add(hockey.Name, hockey);
    }
Esempio n. 6
0
        public void Update()
        {
            IEnumerable <string> sportNames = facade.GetAll();

            Sports.Clear();
            foreach (string sportName in sportNames)
            {
                Sports.Add(sportName);
            }

            RaisePropertyChangedEvent("SelectedSport");
        }
 private void ClearFields()
 {
     Member = new Member();
     MemberClubs.Clear();
     MemberSports.Clear();
     Clubs.Clear();
     Sports.Clear();
     foreach (Sport s in AllSports)
     {
         Sports.Add(s);
     }
 }
        private void ListView_ItemSelection(object sender, SelectionChangedEventArgs e)
        {
            var item = (sender as ListView).SelectedItem as Member;

            if (item != null)
            {
                Member       = item as Member;
                MemberClubs  = new ObservableCollection <Club>();
                MemberSports = new ObservableCollection <Sport>();
                Clubs.Clear();
                Sports.Clear();
                foreach (Sport s in AllSports)
                {
                    Sports.Add(s);
                }

                foreach (Club club in Member.Clubs)
                {
                    MemberClubs.Add(club);
                }

                foreach (Sport sport in Member.Sports)
                {
                    MemberSports.Add(sport);
                    foreach (Club c in sport.Clubs)
                    {
                        Clubs.Add(c);
                    }
                }

                foreach (Club club in MemberClubs)
                {
                    var filteredClub = Clubs.FirstOrDefault(c => c.Id == club.Id);
                    Clubs.Remove(filteredClub);
                }

                foreach (Sport sport in MemberSports)
                {
                    var filteredSport = AllSports.FirstOrDefault(s => s.Id == sport.Id);
                    Sports.Remove(filteredSport);
                }
            }
        }
Esempio n. 9
0
        public Event(DataList data, bool defaultId = false)
        {
            Init();

            if (data == null)
            {
                return;
            }

            try
            {
                object idObj = data.Get("id");
                if (idObj != null && !defaultId)
                {
                    Id = (int)idObj;
                }

                // Basic conversions
                object nameObj = data.Get("name");
                if (nameObj != null)
                {
                    Name = (string)nameObj;
                }
                object authorObj = data.Get("author");
                if (authorObj != null)
                {
                    Author = (int)authorObj;
                }
                object coordinatesObj = data.Get("coordinates");
                if (coordinatesObj != null)
                {
                    object latitudeObj  = ((DataList)coordinatesObj).Get(0);
                    object longitudeObj = ((DataList)coordinatesObj).Get(1);
                    if (latitudeObj != null)
                    {
                        Latitude = (double)latitudeObj;
                    }
                    if (longitudeObj != null)
                    {
                        Longitude = (double)longitudeObj;
                    }
                }
                object addressObj = data.Get("address");
                if (addressObj != null)
                {
                    Address = AddressInfo.FromString((string)addressObj);
                }
                try
                {
                    object startDateObj = data.Get("start_date");
                    if (startDateObj != null)
                    {
                        StartDate = DateTime.ParseExact((string)startDateObj, "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
                    }
                }
                catch (FormatException)
                {
                    // TODO: log incident
                }
                object priceObj = data.Get("price");
                if (priceObj != null)
                {
                    Price = (decimal)priceObj;
                }
                object descriptionObj = data.Get("description");
                if (descriptionObj != null)
                {
                    Description = (string)descriptionObj;
                }
                object visibleObj = data.Get("visible");
                if (visibleObj != null)
                {
                    Visible = (bool)visibleObj;
                }

                // Complex conversions
                object sportsObj = data.Get("sports");
                if (sportsObj != null)
                {
                    foreach (ListItem sport in (DataList)sportsObj)
                    {
                        Sports.Add((string)sport.item);
                    }
                }
                object linksObj = data.Get("links");
                if (linksObj != null)
                {
                    foreach (ListItem link in (DataList)linksObj)
                    {
                        Links.Add((string)link.item);
                    }
                }
                object imagesObj = data.Get("images");
                if (imagesObj != null)
                {
                    foreach (ListItem image in (DataList)imagesObj)
                    {
                        Images.Add((string)image.item);
                    }
                }
                object tagsObj = data.Get("tags");
                if (tagsObj != null)
                {
                    Tags = ((string)tagsObj);
                }
            }
            catch (InvalidCastException)
            {
                // TODO: log incident
            }
        }
Esempio n. 10
0
        public void SynchEntities()
        {
            try
            {
                var scales = client.GetAllScales();
                foreach (var a in scales)
                {
                    var scale = Scales.SingleOrDefault(q => q.ID == a.Id);
                    if (scale == null)
                    {
                        Scales.Add(new Scale(a.Id, a.Name));
                    }
                    else
                    {
                        scale.Update(a.Name);
                    }
                }
                var sports = client.GetAllSports();
                foreach (var a in sports)
                {
                    var sport = Sports.SingleOrDefault(q => q.ID == a.Id);
                    if (sport == null)
                    {
                        sport = new Sport(a.Id, a.Name);
                        Sports.Add(sport);
                    }
                    else
                    {
                        sport.Update(a.Name);
                    }
                    var disciplines = client.GetDiscipliniesFromSport(a.Id);
                    foreach (var disc in disciplines)
                    {
                        var discipline = Disciplines.SingleOrDefault(q => q.ID == disc.Id);
                        if (discipline == null)
                        {
                            discipline = new Discipline(disc.Id, disc.Name, sport, Scales.Single(q => q.ID == disc.ScaleId), disc.Description);
                            Disciplines.Add(discipline);
                        }
                        else
                        {
                            discipline.Update(disc.Name, sport, Scales.Single(q => q.ID == disc.ScaleId), disc.Description);
                        }
                        var goals = client.GetGoalsFromDiscipline(disc.Id);
                        foreach (var g in goals)
                        {
                            var goal = Goals.SingleOrDefault(q => q.ID == g.Id);
                            if (goal == null)
                            {
                                goal = new Goal(g.Id, g.Value, discipline, g.PeriodDays, g.Description, Users.SingleOrDefault(q => q.ID == g.OwnerId));
                                Goals.Add(goal);
                            }
                            else
                            {
                                goal.Update(g.Value, discipline, g.PeriodDays, g.Description, Users.Single(q => q.ID == g.OwnerId));
                            }

                            var users_goals = client.GetUsers_GoalsFromUser(CurrentUser.ID, goal.ID);
                            foreach (var userg in users_goals)
                            {
                                var user_goal = Users_Goals.SingleOrDefault(q => q.ID == userg.Id);
                                if (user_goal == null)
                                {
                                    user_goal = new User_Goal(userg.Id, CurrentUser, goal, userg.DateStart);
                                    Users_Goals.Add(user_goal);
                                }
                                else
                                {
                                    user_goal.Update(CurrentUser, goal, userg.DateStart);
                                }
                                var stand_datas = client.GetStandart_DataFromGoal(user_goal.Goal.ID);
                                foreach (var s in stand_datas)
                                {
                                    var stand = Standarts_Datas.SingleOrDefault(q => q.ID == s.Id);
                                    if (stand == null)
                                    {
                                        stand = new Standart_Data(s.Id, s.Value, user_goal.Goal, s.Day);
                                        Standarts_Datas.Add(stand);
                                    }
                                    else
                                    {
                                        stand.Update(s.Value, user_goal.Goal, s.Day);
                                    }
                                }
                                var users_data = client.GetUsers_DataFromGoal(userg.GoalId);
                                foreach (var us in users_data)
                                {
                                    var user_data = Users_Datas.SingleOrDefault(q => q.ID == us.Id);
                                    if (user_data == null)
                                    {
                                        user_data = new User_Data(us.Id, user_goal, us.Value, us.Date);
                                        Users_Datas.Add(user_data);
                                    }
                                    else
                                    {
                                        user_data.Update(user_goal, us.Value, us.Date);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
            SaveBinaryFormat();
        }
Esempio n. 11
0
        public async void Seed()
        {
            Random rnd = new Random();

            if (!Players.Any() && !FootballPlayers.Any() && !Sports.Any())
            {
                Sport Football = new Football();
                Sports.Add(Football);

                var Andrew = new Player()
                {
                    FirstName = "Andrew",
                    LastName  = "Sharrock",
                };
                var Stuart = new Player()
                {
                    FirstName = "Stuart",
                    LastName  = "Sharrock",
                };
                var Jim = new Player()
                {
                    FirstName = "Jim",
                    LastName  = "Sharrock",
                };
                var Gill = new Player()
                {
                    FirstName = "Gill",
                    LastName  = "Sharrock",
                };
                var Stevie = new Player()
                {
                    FirstName = "Stevie",
                    LastName  = "Sharrock",
                };
                var Carly = new Player()
                {
                    FirstName = "Carly",
                    LastName  = "Richardson"
                };
                var Timme = new Player()
                {
                    FirstName = "Timme",
                    LastName  = "Martin",
                };
                var Pete = new Player()
                {
                    FirstName = "Pete",
                    LastName  = "Skipp",
                };
                var Paul = new Player()
                {
                    FirstName = "Paul",
                    LastName  = "French",
                };
                var Leeroy = new Player()
                {
                    FirstName = "Leeroy",
                    LastName  = "Jenkins",
                };

                await Players.AddAsync(Andrew);

                await Players.AddAsync(Stuart);

                await Players.AddAsync(Jim);

                await Players.AddAsync(Gill);

                await Players.AddAsync(Stevie);

                await Players.AddAsync(Carly);

                await Players.AddAsync(Timme);

                await Players.AddAsync(Pete);

                await Players.AddAsync(Paul);

                await Players.AddAsync(Leeroy);

                SaveChanges();

                var AndrewFootballPlayer = new FootballPlayer()
                {
                    PlayerId       = Andrew.Id,
                    CentreBack     = rnd.Next(1, 101),
                    CentreMidfield = rnd.Next(1, 101),
                    Forward        = rnd.Next(1, 101)
                };
                var StuartFootballPlayer = new FootballPlayer()
                {
                    PlayerId       = Stuart.Id,
                    CentreBack     = rnd.Next(1, 101),
                    CentreMidfield = rnd.Next(1, 101),
                    Forward        = rnd.Next(1, 101)
                };
                var JimFootballPlayer = new FootballPlayer()
                {
                    PlayerId       = Jim.Id,
                    CentreBack     = rnd.Next(1, 101),
                    CentreMidfield = rnd.Next(1, 101),
                    Forward        = rnd.Next(1, 101)
                };
                var GillFootballPlayer = new FootballPlayer()
                {
                    PlayerId       = Gill.Id,
                    CentreBack     = rnd.Next(1, 101),
                    CentreMidfield = rnd.Next(1, 101),
                    Forward        = rnd.Next(1, 101)
                };
                var StevieFootballPlayer = new FootballPlayer()
                {
                    PlayerId       = Stevie.Id,
                    CentreBack     = rnd.Next(1, 101),
                    CentreMidfield = rnd.Next(1, 101),
                    Forward        = rnd.Next(1, 101)
                };
                var CarlyFootballPlayer = new FootballPlayer()
                {
                    PlayerId       = Carly.Id,
                    CentreBack     = rnd.Next(1, 101),
                    CentreMidfield = rnd.Next(1, 101),
                    Forward        = rnd.Next(1, 101)
                };
                var TimmeFootballPlayer = new FootballPlayer()
                {
                    PlayerId       = Timme.Id,
                    CentreBack     = rnd.Next(1, 101),
                    CentreMidfield = rnd.Next(1, 101),
                    Forward        = rnd.Next(1, 101)
                };;
                var PeteFootballPlayer = new FootballPlayer()
                {
                    PlayerId       = Pete.Id,
                    CentreBack     = rnd.Next(1, 101),
                    CentreMidfield = rnd.Next(1, 101),
                    Forward        = rnd.Next(1, 101)
                };
                var PaulFootballPlayer = new FootballPlayer()
                {
                    PlayerId       = Paul.Id,
                    CentreBack     = rnd.Next(1, 101),
                    CentreMidfield = rnd.Next(1, 101),
                    Forward        = rnd.Next(1, 101)
                };
                var LeeroyFootballPlayer = new FootballPlayer()
                {
                    PlayerId       = Leeroy.Id,
                    CentreBack     = rnd.Next(1, 101),
                    CentreMidfield = rnd.Next(1, 101),
                    Forward        = rnd.Next(1, 101)
                };

                AndrewFootballPlayer.SetRating(); StuartFootballPlayer.SetRating(); JimFootballPlayer.SetRating();
                GillFootballPlayer.SetRating(); StevieFootballPlayer.SetRating(); CarlyFootballPlayer.SetRating();
                TimmeFootballPlayer.SetRating(); PeteFootballPlayer.SetRating(); PaulFootballPlayer.SetRating();
                LeeroyFootballPlayer.SetRating();

                await FootballPlayers.AddAsync(AndrewFootballPlayer);

                await FootballPlayers.AddAsync(StuartFootballPlayer);

                await FootballPlayers.AddAsync(JimFootballPlayer);

                await FootballPlayers.AddAsync(GillFootballPlayer);

                await FootballPlayers.AddAsync(StevieFootballPlayer);

                await FootballPlayers.AddAsync(CarlyFootballPlayer);

                await FootballPlayers.AddAsync(TimmeFootballPlayer);

                await FootballPlayers.AddAsync(PeteFootballPlayer);

                await FootballPlayers.AddAsync(PaulFootballPlayer);

                await FootballPlayers.AddAsync(LeeroyFootballPlayer);

                SaveChanges();

                await PlayerSports.AddAsync(new PlayerSports()
                {
                    PlayerId = Andrew.Id,
                    SportId  = Football.Id,
                });

                await PlayerSports.AddAsync(new PlayerSports()
                {
                    PlayerId = Stuart.Id,
                    SportId  = Football.Id,
                });

                await PlayerSports.AddAsync(new PlayerSports()
                {
                    PlayerId = Jim.Id,
                    SportId  = Football.Id,
                });

                await PlayerSports.AddAsync(new PlayerSports()
                {
                    PlayerId = Gill.Id,
                    SportId  = Football.Id,
                });

                await PlayerSports.AddAsync(new PlayerSports()
                {
                    PlayerId = Stevie.Id,
                    SportId  = Football.Id,
                });

                await PlayerSports.AddAsync(new PlayerSports()
                {
                    PlayerId = Carly.Id,
                    SportId  = Football.Id,
                });

                await PlayerSports.AddAsync(new PlayerSports()
                {
                    PlayerId = Timme.Id,
                    SportId  = Football.Id,
                });

                await PlayerSports.AddAsync(new PlayerSports()
                {
                    PlayerId = Pete.Id,
                    SportId  = Football.Id,
                });

                await PlayerSports.AddAsync(new PlayerSports()
                {
                    PlayerId = Paul.Id,
                    SportId  = Football.Id,
                });

                await PlayerSports.AddAsync(new PlayerSports()
                {
                    PlayerId = Leeroy.Id,
                    SportId  = Football.Id,
                });


                SaveChanges();
            }
        }