コード例 #1
0
 public static void Exists(string town, PhotoShareContext context)
 {
     if (context.Towns.Any(t => t.Name == town))
     {
         throw new ArgumentException(TownMessages.InvalidTown(town));
     }
 }
コード例 #2
0
        // AddTown <townName> <countryName>
        public void Execute()
        {
            AddTownValidator.Exists(this.TownName, context);

            using (PhotoShareContext context = new PhotoShareContext())
            {
                Town town = new Town
                {
                    Name    = this.TownName,
                    Country = this.Country
                };

                context.Towns.Add(town);
                context.SaveChanges();

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(TownMessages.Succsess(this.TownName));
            }
        }
コード例 #3
0
 //listeners
 private void GameLoop_SaveLoaded(object sender, SaveLoadedEventArgs e)
 {
     this.morningMessages = new MorningMessages(mainHelper);
     this.townMessages    = new TownMessages(mainHelper);
 }