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(AddPaymentCommand command) { int clientId = SessionRepository.GetClientIdOfSession(command.sessionToken); if (clientId == -1) { throw new Exception(); } var order = DatabaseQueryProcessor.GetTheMostRecentOrder(clientId); if (order == null) { throw new Exception(); } var totalPrice = DatabaseQueryProcessor.GetTotal(order.orderId); DatabaseQueryProcessor.CreateNewPayment( command.paymentId, order.orderId, totalPrice, DateTime.Now.ToString("yyyy-MM-dd") ); ThreadPool.QueueUserWorkItem( o => new OrderPlacementEmail().Send(clientId)); var isSuccessPayment = PaymentMethod.Check(command.paymentId, totalPrice); if (isSuccessPayment) { DatabaseQueryProcessor.UpdateOrder(order.orderId, 1); ThreadPool.QueueUserWorkItem(o => new SuccessfullPaymentEmail().Send(clientId)); } else { ThreadPool.QueueUserWorkItem(o => new UnsuccessfullPaymentEmail().Send(clientId)); } return(new SuccessInfoDto { isSuccess = true }); }