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", "*****@*****.**"); }
public IResult Handle(AddAddressCommand command) { int clientId = SessionRepository.GetClientIdOfSession(command.sessionToken); if (clientId == -1) { throw new Exception(); } if (!InputChecker.isValidName(command.country) || !InputChecker.isValidName(command.city) || !InputChecker.isValidName(command.street) || !InputChecker.isValidApartmentNumber(command.apartmentNumber)) { throw new Exception(); } var duplicate = DatabaseQueryProcessor.GetAddress(clientId, command.country, command.city, command.street, command.ZIPCode, command.buildingNumber, command.apartmentNumber); if (duplicate != null) { DatabaseQueryProcessor.UpdateAddress(duplicate.addressId, true); } else { DatabaseQueryProcessor.CreateNewAddress( clientId, command.country, command.city, command.street, command.ZIPCode, command.buildingNumber, command.apartmentNumber ); } return(new GetAddressBookQueryHandler().Handle(new GetAddressBookQuery() { sessionToken = command.sessionToken })); }