示例#1
0
        // GET: Order
        public ActionResult Index()
        {
            List <OrderPO> mappedOrders = null;
            List <OrderDO> allOrders    = null;

            try
            {
                allOrders = _orderDataAccess.ReadAllOrders();

                mappedOrders = new List <OrderPO>();

                foreach (OrderDO dataObject in allOrders)
                {
                    mappedOrders.Add(OrderMappers.OrderDOtoPO(dataObject));
                }
            }

            catch (Exception exception)
            {
                ErrorLogger.LogExceptions(exception);
            }

            finally
            { }

            return(View(mappedOrders));
        }
示例#2
0
        public ActionResult UpdateOrder(int orderID)
        {
            OrderDO      item     = null;
            OrderPO      display  = null;
            ActionResult response = RedirectToAction("Index", "Home");

            //Available to all roles
            if (Session["RoleID"] != null)
            {
                try
                {
                    item    = _orderDataAccess.ReadIndividualOrder(orderID);
                    display = OrderMappers.OrderDOtoPO(item);

                    //Filling selectlist
                    foreach (ProductDO dataObject in _productDataAccess.ReadAllProducts())
                    {
                        //declaring a selectlistitem for the list in the OrderPO property ProductsDropDown
                        SelectListItem listItem = new SelectListItem();
                        //Assigning the product's name to the listitem's text
                        listItem.Text = dataObject.Name;
                        //Assigning the product's ID to the listitem's value
                        listItem.Value = dataObject.ProductID.ToString();

                        //Adding the listitem, with its text and value, to the ProductsDropDown property of the OrderPO object
                        display.ProductsDropDown.Add(listItem);
                    }

                    //Setting the dropdown list to the correct product:
                    display.ProductID = item.ProductID;
                }

                catch (Exception exception)
                {
                    ErrorLogger.LogExceptions(exception);
                    response = View(orderID);
                }

                finally
                { }

                response = View(display);
            }

            else
            {
                response = RedirectToAction("Index", "Home");
            }

            return(response);
        }