private static ServiceInteraction AddTown(string county, string townName, ITownService townService)
        {
            Console.WriteLine($"Adding town: {townName} to county: {county}.");
            var serviceInteraction = townService.AddTown(county, townName).GetAwaiter().GetResult();

            DescribeServiceInteraction(serviceInteraction);
            return(serviceInteraction);
        }
Esempio n. 2
0
        // AddTown <townName> <countryName>
        public string Execute(string[] data)
        {
            string townName = data[0];
            string country  = data[1];

            Town town = service.AddTown(townName, country);

            return($"Town {town.Name} was added successfully!");
        }
        // AddTown <townName> <countryName>
        public string Execute(params string[] data)
        {
            if (Session.User is null)
            {
                throw new ArgumentException("Invalid credentials!");
            }

            var townName = data[0];
            var country  = data[1];

            townService.AddTown(townName, country);

            return($"{townName} was added to database!");
        }
Esempio n. 4
0
        // AddTown <townName> <countryName>
        public string Execute(string command, string[] data)
        {
            if (Session.User == null)
            {
                throw new ArgumentException("You should login first!");
            }

            if (data.Length < 2)
            {
                throw new InvalidOperationException($"Command {command} not valid!");
            }

            string townName    = data[0];
            string countryName = data[1];

            return(townService.AddTown(townName, countryName));
        }
        public string Execute(IEnumerable <string> parameters)
        {
            var args = parameters.ToList();

            if (args.Count != 5)
            {
                throw new InvalidUserServiceParametersExeption("Invalid number of parameters.");
            }
            var firstName  = args[0];
            var middleName = args[1];
            var lastName   = args[2];

            var town       = townService.AddTown(args[4]);
            var newAddress = addressService.AddAddress(args[3], town);

            var user = this.usersServices.UpdateUserAddress(firstName, middleName, lastName, newAddress);

            return($"The address of user: {user.FirstName} was successfully updated to {user.Address.StreetAddress}, {user.Address.Town.TownName}");
        }
Esempio n. 6
0
        public string Execute(IEnumerable <string> parameters)
        {
            var args = parameters.ToList();

            if (args.Count != 6)
            {
                throw new InvalidUserServiceParametersExeption("Invalid number of parameters.");
            }
            var  firstName  = args[0];
            var  middleName = args[1];
            var  lastName   = args[2];
            var  phone      = args[3];
            var  addedOn    = DateTime.Now;
            bool isDeleted  = false;

            var town    = townService.AddTown(args[5]);
            var address = addressService.AddAddress(args[4], town);

            var user = usersServices.AddUser(firstName, middleName, lastName, phone, addedOn, isDeleted, address);

            return($"New user {user.FirstName} was added successfully on {user.AddOnDate}.");
        }