コード例 #1
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();
         }
     }
 }
コード例 #2
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();
            }
        }