Example #1
0
        /// <summary>
        /// Get all itens filtering direct in DB. Up: More optimized because filters DB. Down: less flexible, don't support dynamic filters.
        /// </summary>
        /// <param name="generalBodyGet"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public List <GetOrdersView> GetAllWithDBFilter(GeneralBodyGet generalBodyGet, out RestExceptionError error)
        {
            try
            {
                if ((generalBodyGet == null) || (generalBodyGet.Filters == null) || (generalBodyGet.Filters.Count == 0))
                {
                    error = new RestExceptionError();
                    error.ExceptionMessage = "";
                    error.InternalMessage  = "Url does not contains filter section";
                }

                error = null;
                OrdersBsn bsn = new OrdersBsn(restConfig);
                List <DataFilterExpressionDB> dbFilter = HelperRESTFilterToDB.FilterRestFilterToDBExpression(generalBodyGet.Filters);
                List <OrdersInfo>             dbItems  = bsn.GetAll(dbFilter);
                List <GetOrdersView>          result   = new List <GetOrdersView>();
                foreach (OrdersInfo item in dbItems)
                {
                    GetOrdersView view = new GetOrdersView();
                    Cloner.CopyAllTo(typeof(OrdersInfo), item, typeof(GetOrdersView), view);
                    result.Add(view);
                }

                return(result);
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.ExceptionMessage = ex.Message;
            }
            return(null);
        }
Example #2
0
        public ModelNotifiedForOrders GetOrdersByID(int OrderID, out string error)
        {
            error = null;
            OrdersGenericREST      OrdersGenericREST      = new OrdersGenericREST(wpfConfig);
            GetOrdersView          getOrdersView          = OrdersGenericREST.GetByPK <GetOrdersView>(OrderID, out error)[0];
            ModelNotifiedForOrders modelNotifiedForOrders = new ModelNotifiedForOrders();

            Cloner.CopyAllTo(typeof(GetOrdersView), getOrdersView, typeof(ModelNotifiedForOrders), modelNotifiedForOrders);
            return(modelNotifiedForOrders);
        }
        public GetOrdersView GetOrders()
        {
            var getOrdersView = new GetOrdersView()
            {
                Orders = new List <OrderViewItem>()
            };

            var orders = _orderRepository.GetAll();

            foreach (var order in orders)
            {
                var orderView = OrderMap(order);
                getOrdersView.Orders.Add(orderView);
            }

            return(getOrdersView);
        }
        public GetOrdersView GetOrdersByUser(string userName)
        {
            var getOrdersView = new GetOrdersView();
            var user          = _userRepository.GetByEmail(userName);

            getOrdersView.Orders = new List <OrderViewItem>();

            var orders = _orderRepository.GetAll();

            foreach (var order in orders)
            {
                if (order.UserId == user.Id)
                {
                    var orderView = OrderMap(order);
                    getOrdersView.Orders.Add(orderView);
                }
            }

            return(getOrdersView);
        }
        public GetOrdersView GetOrdersByStatus(OrderStatus status)
        {
            var getOrdersView = new GetOrdersView()
            {
                Orders = new List <OrderViewItem>()
            };

            var orders = _orderRepository.GetAll();

            foreach (var order in orders)
            {
                if (order.Status == status)
                {
                    var orderView = OrderMap(order);
                    getOrdersView.Orders.Add(orderView);
                }
            }

            return(getOrdersView);
        }
Example #6
0
        public List <GetOrdersView> GetAll(out RestExceptionError error)
        {
            try
            {
                error = null;
                OrdersBsn            bsn     = new OrdersBsn(restConfig);
                List <OrdersInfo>    dbItems = bsn.GetAll();
                List <GetOrdersView> result  = new List <GetOrdersView>();
                foreach (OrdersInfo item in dbItems)
                {
                    GetOrdersView view = new GetOrdersView();
                    Cloner.CopyAllTo(typeof(OrdersInfo), item, typeof(GetOrdersView), view);
                    result.Add(view);
                }

                return(result);
            }
            catch (Exception ex)
            {
                error = new RestExceptionError();
                error.ExceptionMessage = ex.Message;
            }
            return(null);
        }