Exemplo n.º 1
0
        /*UNUSED: (mech detail view checkboxes to toggle status need a dedicated manager function
         * to not reassign most recent mechanic when toggling ( WorkOrdersStatusById does this right now)
         *
         * //Change Status by Id from a mechanic details view.
         * //This view has 2 tables: one for a mechanic's active orders and one
         * //for previously assigned ones, so the partial view populates these
         * //USES PARTIAL VIEW: _MechDetailWorkOrders
         * [Route("workorders/ChangeStatusFromMechView/{mechId}{workOrderId}")]
         * public ActionResult ChangeStatusFromMechView(int mechId, int workOrderId)
         * {
         * //try to change the workorder's status:
         * var theWorkOrder = m.WorkOrdersStatusById(workOrderId);
         *
         * //Get the mechanic details view object with formatted workorders
         * //(just grab the whole object, and use what's needed in the partial view).
         * //If anything's changed, it will be returned as changed, and if it hasn't,
         * //the partial view will be the same as the original view.
         * var returnMe = m.MechanicGetByIdWithWorkOrders(mechId);
         *
         * //set an error message if the workorder was not changed
         * if (theWorkOrder == null)
         * {   //if the update did not work, return the error message partial view
         *  returnMe.Error = "Error retrieving target work order";
         * }
         * return PartialView("_MechDetailWorkOrders", returnMe);
         * }*/
        //---------------------------------------------

        // GET: WorkOrders/Create : Render a workorder Creation form
        public ActionResult Create()
        {
            var form = new WorkOrderAddForm();

            form.CustomerSearchList = new SelectList(m.CustomersGetAll(), "Id", "CustListLabel"); //TODO improve by displaying First and last name, phone and email
            form.BicycleSearchList  = new SelectList(new List <BicycleBase>());                   // empty list
            form.MechanicSearchList = new SelectList(m.MechanicsGetWithWorkOrders(), "Id", "MechListLabel");

            return(View(form));
        }
Exemplo n.º 2
0
        public ActionResult BicycleSearch(int?custId)
        {
            var found = m.BicycleGetByCustId(custId.GetValueOrDefault());

            if (found == null)
            {
                found = m.BicyclesGetWithManuModel();
            }                                                                                                        //TODO: check if safe when search box empty
                                                                                                                     // Create a new selectlist (this is a partial view)
            var newList = new WorkOrderAddForm();                                                                    //uses the same view model class as the view we called the ajax function from

            newList.BicycleSearchList = new SelectList(found, dataValueField: "Id", dataTextField: "BikeListLabel"); //set the partial view's selectList to hold our search results

            return(PartialView("_BikeList", newList));
        }