Esempio n. 1
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", "*****@*****.**");
        }
        public IResult Handle(AddComplaintCommand command)
        {
            int clientId = SessionRepository.GetClientIdOfSession(command.sessionToken);

            if (clientId == -1)
            {
                throw new Exception();
            }

            var order = DatabaseQueryProcessor.GetOrder(command.orderId);

            if (order == null)
            {
                throw new Exception();
            }

            if (order.clientId != clientId)
            {
                throw new Exception();
            }

            var foundComplaint = DatabaseQueryProcessor.GetComplaint(order.orderId);

            if (foundComplaint != null)
            {
                throw new Exception();
            }

            DatabaseQueryProcessor.CreateNewComplaint(
                command.orderId,
                0,
                command.description,
                DateTime.Now.ToString("yyyy-MM-dd"),
                false
                );

            return(new SuccessInfoDto()
            {
                isSuccess = true
            });
        }