Пример #1
0
        public Response<List<Order>> DisplayOrders(DateTime date)
        {
            var repo =  new OrderRepository();

            var response = new Response<List<Order>>();

            try
            {
                var orders = repo.LoadOrders(date);

                if (orders == null)
                {
                    response.Success = false;
                    response.Message = "A file with that date was not found.";
                }

                else
                {
                    response.Success = true;
                    response.Data = orders;
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = "There was an error with Loading the File: " + ex.Message;
                repo.ErrorLogger(ex.Message);
            }

            return response;
        }
Пример #2
0
        public Response<Order> RemoveOrder(int orderNumber, DateTime date)
        {
            OrderRepository repo = new OrderRepository();
            var response = new Response<Order>();

            try
            {
                repo.DeleteOrder(orderNumber, date);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = "There was an error with deleting the order: " + ex.Message;
                repo.ErrorLogger(ex.Message);
            }

            //check to see if it deleted the last order in the file, if so, delete the file also
            var orders = repo.LoadOrders(date);
            if (orders.Count == 0)
            {
               repo.DeleteFile();
            }

            return response;
        }