Ejemplo n.º 1
0
        private void ClearButton_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new ActiveRosterDBEntities())
            {
                List <tbl_Team> teams = context.tbl_Team.ToList();
                foreach (tbl_Team team in teams)
                {
                    List <tbl_Player> players = context.tbl_Player.Where(p => p.Team == team.Id).ToList();

                    foreach (tbl_Player player in players)
                    {
                        context.tbl_Player.Remove(player);
                    }

                    context.tbl_Team.Remove(team);

                    context.SaveChanges();
                }

                teams = new List <tbl_Team>();
                ListViewMenu.ItemsSource = teams;

                GridMain.Children.Clear();
            }
        }
Ejemplo n.º 2
0
        public static void SavePlayer(string registrationNumber, string first, string last, string weight, string dateOfBirth, string level, int team)
        {
            decimal convertedWeight = 0.0m;

            try
            {
                convertedWeight = Convert.ToDecimal(weight);
            }
            catch (Exception ex)
            {
            }

            tbl_Player player = new tbl_Player()
            {
                FirstName          = first,
                LastName           = last,
                Weight             = convertedWeight,
                RegistrationNumber = registrationNumber,
                DateOfBirth        = DateTime.ParseExact(dateOfBirth, "M/d/yyyy h:mm:ss tt", System.Globalization.CultureInfo.CurrentCulture),
                Team = team
            };

            using (var context = new ActiveRosterDBEntities())
            {
                context.tbl_Player.Add(player);
                context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
 public static void SaveImage(string playerNumber, Image image)
 {
     using (var context = new ActiveRosterDBEntities())
     {
         tbl_Player player = context.tbl_Player.Where(p => p.RegistrationNumber.Contains(playerNumber)).FirstOrDefault();
         if (player != null)
         {
             player.Image = ImageHelper.ImageToByteArray(image);
             context.SaveChanges();
         }
     }
 }
Ejemplo n.º 4
0
        public static int SaveTeam(string teamName)
        {
            tbl_Team team = new tbl_Team()
            {
                Name = teamName
            };

            using (var context = new ActiveRosterDBEntities())
            {
                context.tbl_Team.Add(team);
                context.SaveChanges();
            }

            return(team.Id);
        }