Beispiel #1
0
        // AddTown <townName> <countryName>
        public string Execute(string[] data)
        {
            if (!userSessionService.IsLoggedIn())
            {
                throw new InvalidOperationException("Invalid credentials!");
            }
            string townName = data[0];
            string country  = data[1];

            var townExists = townService.Exists(townName);

            if (townExists)
            {
                throw new ArgumentException($"Town {townName} was already added!");
            }
            var townDto = new TownDto()
            {
                TownName = townName, CountryName = country
            };
            var town = townService.Add(townName, country);

            return($"Town {townName} was added successfully!");
        }