public IResult Handle(RegisterNewClientCommand command)
        {
            if (!InputChecker.isValidEmail(command.email) ||
                !InputChecker.isValidName(command.firstName) ||
                !InputChecker.isValidName(command.lastName) ||
                (command.receiveNewsletterEmail &&
                 !InputChecker.isValidEmail(command.newsletterEmail)))
            {
                throw new Exception();
            }

            var clients      = DatabaseQueryProcessor.GetClients();
            var foundClients = clients.FindAll(c => c.email == command.email);

            if (foundClients.Count != 0)
            {
                throw new Exception();
            }

            var clientId = DatabaseQueryProcessor.CreateNewClient(
                command.email,
                command.firstName,
                command.lastName,
                PasswordEncryptor.encryptSha256(command.password),
                command.receiveNewsletterEmail ? command.newsletterEmail : ""
                );

            ThreadPool.QueueUserWorkItem(o => new RegistrationEmail().Send(clientId));


            return(new SuccessInfoDto()
            {
                isSuccess = true
            });
        }
Beispiel #2
0
        public static void FillTheDatabase()
        {
            DatabaseQueryProcessor.CreateNewProduct("Lavazza", 1500, "./img.jpg", "100% Arabica", "Good");
            DatabaseQueryProcessor.CreateNewProduct("Vergnano", 2500, "./img.jpg", "100% Robusta", "Strong");

            DatabaseQueryProcessor.CreateNewWorker(WorkerRole.a, "*****@*****.**", "240be518fabd2724ddb6f04eeb1da5967448d7e831c08c8fa822809f74c720a9");
            DatabaseQueryProcessor.CreateNewWorker(WorkerRole.b, "*****@*****.**", "240be518fabd2724ddb6f04eeb1da5967448d7e831c08c8fa822809f74c720a9");

            DatabaseQueryProcessor.CreateNewClient("*****@*****.**", "Jane", "Doe", "240be518fabd2724ddb6f04eeb1da5967448d7e831c08c8fa822809f74c720a9", "*****@*****.**");
            DatabaseQueryProcessor.CreateNewAddress(0, "Poland", "Gdynia", "Rzemieslnicza", 30445, 12, "1a");
            DatabaseQueryProcessor.CreateNewAddress(0, "Poland", "Warsaw", "Grodzka", 25487, 23, "");

            DatabaseQueryProcessor.CreateNewOrder(0, 0, 0, 1, "2018-05-12");
            DatabaseQueryProcessor.CreateNewOrderEntry(0, 0, 1);
            DatabaseQueryProcessor.CreateNewOrderEntry(0, 1, 2);

            DatabaseQueryProcessor.CreateNewOrder(0, 1, 1, 0, "2018-10-12");
            DatabaseQueryProcessor.CreateNewOrderEntry(1, 0, 1);
            DatabaseQueryProcessor.UpdateOrder(1, 1);
            DatabaseQueryProcessor.UpdateOrder(1, "2018-10-14");
            DatabaseQueryProcessor.CreateNewComplaint(1, 1, "I am dissatisfied", "2018-10-15", true);

            DatabaseQueryProcessor.CreateNewClient("*****@*****.**", "John", "Doe", "240be518fabd2724ddb6f04eeb1da5967448d7e831c08c8fa822809f74c720a9", "*****@*****.**");
            DatabaseQueryProcessor.CreateNewAddress(1, "Poland", "Cracow", "Krakowska", 30000, 1, "");

            DatabaseQueryProcessor.CreateNewOrder(1, 0, 2, 0, "2018-06-12");
            DatabaseQueryProcessor.CreateNewOrderEntry(2, 1, 1);

            DatabaseQueryProcessor.CreateNewClient("*****@*****.**", "Anne", "Bottom", "240be518fabd2724ddb6f04eeb1da5967448d7e831c08c8fa822809f74c720a9", "*****@*****.**");
        }