Esempio n. 1
0
        public StatusCodeResult DenyOrder([FromBody] OrderInfoDTO data)
        {
            if (SessionController.sm.ifTokenValidForEmployee(data.authToken))
            {
                if (EmployeeOrderQueue.denyOrder(data.orderID))
                {
                    return(StatusCode(200));
                }

                //Internal Server Error
                return(StatusCode(500));
            }
            else
            {
                return(StatusCode(401));
            }
        }
Esempio n. 2
0
        public string GetOrderQueue([FromBody] OrderInfoDTO data)
        {
            // validate that they are an employee and have valid token
            if (SessionController.sm.ifTokenValidForEmployee(data.authToken))
            {
                var          DTO   = new OrderQueueDTO();
                List <Order> queue = EmployeeOrderQueue.getOrderQueue();
                foreach (var order in queue)
                {
                    //TODO: don't pass in total from frontend
                    DTO.populateOrder(order.orderID, order.userID.ToString(), order.firstName, order.lastName,
                                      order.getTotal().ToString(), order.getDate().ToString(), order.getItemsDictionary());
                }

                string output = JsonConvert.SerializeObject(DTO);
                return(output);
            }
            else
            {
                return("");
            }
        }
Esempio n. 3
0
        public StatusCodeResult SubmitOrder([FromBody] OrderInfoDTO data)
        {
            if (SessionController.sm.ifTokenValid(data.authToken))
            {
                //TODO: populate and create order id
                string orderID = EmployeeOrderQueue.generateOrderID();

                if (orderID is null)
                {
                    return(StatusCode(500));
                }

                EmployeeOrderQueue.addOrder(new Order(orderID, data.userID, data.firstName, data.lastName,
                                                      data.returnItemsAsDictionary(), data.total, DateTime.Now));

                return(StatusCode(200));
            }
            else
            {
                return(StatusCode(401));
            }
        }
Esempio n. 4
0
 public StatusCodeResult ApproveOrder([FromBody] OrderInfoDTO data)
 {
     if (SessionController.sm.ifTokenValidForEmployee(data.authToken))
     {
         int result = EmployeeOrderQueue.approveOrder(data.orderID);
         if (result == 1)
         {
             return(StatusCode(200));
         }
         else if (result == 0)
         {
             return(StatusCode(403));
         }
         else
         {
             //Internal Server Error
             return(StatusCode(500));
         }
     }
     else
     {
         return(StatusCode(401));
     }
 }