Exemplo n.º 1
0
        public void ModifyPlayer(String oldName, String newName)
        {
            Constants constants = new Constants();

            if (CheckOldName(oldName))
            {
                if (!CheckNewName(newName))
                {
                    using (var context = new TournamentDBContext())
                    {
                        var player = context.Player.First(Player => Player.Name == oldName);
                        player.Name         = newName;
                        player.ModifiedTime = DateTime.Now;
                        constants.FinishModification(newName, oldName);
                        context.SaveChanges();
                    }
                }
                else
                {
                    constants.NameExists();
                }
            }
            else
            {
                constants.NameDoNotExists();
            }
        }
Exemplo n.º 2
0
 public void ModifyTeam(String oldName, String newName)
 {
     using (var context = new TournamentDBContext())
     {
         Constants constants = new Constants();
         if (CheckOldNAme(oldName))
         {
             if (!CheckNewName(newName))
             {
                 var team = context.Team.First(Team => Team.Name == oldName);
                 team.Name         = newName;
                 team.ModifiedTime = DateTime.Now;
                 context.SaveChanges();
             }
             else
             {
                 constants.NameExists();
             }
         }
         else
         {
             constants.NameDoNotExists();
         }
     }
 }
Exemplo n.º 3
0
 public void ModifyCouch(string oldName, string newName)
 {
     using (var context = new TournamentDBContext())
     {
         Constants constants = new Constants();
         if (CheckOldName(oldName))
         {
             if (!CheckNewName(newName))
             {
                 Couch couch = context.Couch.First(Couch => Couch.Name == oldName);
                 couch.Name         = newName;
                 couch.ModifiedTime = DateTime.Now;
                 context.SaveChanges();
                 constants.FinishModification(newName, oldName);
             }
             else
             {
                 constants.NameExists();
             }
         }
         else
         {
             constants.NameDoNotExists();
         }
     }
 }
Exemplo n.º 4
0
        public void CreatePlayer(String Name, DateTime birthDate, int sallary, String position, string teamName)
        {
            if (!CreateValidation(Name) && CheckPlayerTeam(teamName))
            {
                using (var context = new TournamentDBContext())
                {
                    var team   = context.Team.First(Team => Team.Name == teamName);
                    var player = new Player
                    {
                        Id          = Guid.NewGuid(),
                        CreatedTime = DateTime.Now,
                        Name        = Name,
                        BirthDate   = birthDate,
                        Sallary     = sallary,
                        Position    = position,
                        Team        = team,
                        TeamId      = team.Id,
                    };

                    context.Player.Add(player);
                    context.SaveChanges();
                }
            }
            else
            {
                Constants constants = new Constants();
                constants.NameExists();
            }
        }
Exemplo n.º 5
0
        public void CreateCouch(String Name, DateTime BirthDate, int Sallary, string teamName)
        {
            if (!CreateValidation(Name) && CheckTeamName(teamName))
            {
                using (var context = new TournamentDBContext())
                {
                    var team = context.Team.First(Team => Team.Name == teamName);

                    var couch = new Couch
                    {
                        Id          = Guid.NewGuid(),
                        CreatedTime = DateTime.Now,

                        Name      = Name,
                        BirthDate = BirthDate,
                        Sallary   = Sallary,
                        Team      = team,
                        TeamId    = team.Id,
                    };

                    context.Couch.Add(couch);
                    context.SaveChanges();
                }
            }
            else
            {
                Constants constants = new Constants();
                constants.NameExists();
            }
        }
Exemplo n.º 6
0
        public void CreateTitle(String name, DateTime year)
        {
            Constants constants = new Constants();

            if (!ValidateTitle(name, year))
            {
                using (var context = new TournamentDBContext())
                {
                    var title = new Title
                    {
                        Id          = Guid.NewGuid(),
                        CreatedTime = DateTime.Now,

                        Name = name,
                        Year = year,
                    };
                    context.Title.Add(title);
                    context.SaveChanges();
                }
            }
            else
            {
                constants.NameExists();
            }
        }
Exemplo n.º 7
0
 public void DeleteTeam(string name)
 {
     using (var context = new TournamentDBContext())
     {
         var team = context.Team.First(Team => Team.Name == name);
         team.DeletedTime = DateTime.Now;
         Constants constants = new Constants();
         constants.Deleted();
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public void DeletePlayer(string name)
 {
     using (var context = new TournamentDBContext())
     {
         var player = context.Player.First(Player => Player.Name == name);
         player.DeletedTime = DateTime.Now;
         Constants constants = new Constants();
         constants.Deleted();
         context.SaveChanges();
     }
 }
Exemplo n.º 9
0
 public void DeleteCouch(string name)
 {
     using (var context = new TournamentDBContext())
     {
         var couch = context.Couch.First(Couch => Couch.Name == name);
         couch.DeletedTime = DateTime.Now;
         Constants constants = new Constants();
         constants.Deleted();
         context.SaveChanges();
     }
 }
Exemplo n.º 10
0
 public void DeleteTitle(string name)
 {
     using (var context = new TournamentDBContext())
     {
         var title = context.Title.First(Title => Title.Name == name);
         title.DeletedTime = DateTime.Now;
         Constants constants = new Constants();
         constants.Deleted();
         context.SaveChanges();
     }
 }
Exemplo n.º 11
0
        public void CreateTeam(String Name, DateTime FoundationYear)
        {
            using (var context = new TournamentDBContext())
            {
                if (!CreateValidation(Name))
                {
                    var team = new Team
                    {
                        Id          = new Guid(),
                        CreatedTime = DateTime.Now,

                        Name           = Name,
                        FoundationYear = FoundationYear,
                    };
                    context.Team.Add(team);
                    context.SaveChanges();
                }
                else
                {
                    Constants constants = new Constants();
                    constants.NameExists();
                }
            }
        }