Esempio n. 1
0
        // GET: DepartmentController/Edit/5
        public ActionResult Edit(int id)
        {
            Department department = _buisnessLogicClass.GetDepartmentByID(id);


            return(View(department));
        }
        public ActionResult Create(ProductViewModel myProductVM, int DepartmentID)
        {
            if (ModelState.IsValid)
            {
                //Save the product to DB and display the product information...

                Department myDepartment = _buisnessLogicClass.GetDepartmentByID(DepartmentID);
                //Update Product
                Product myProduct = new Product()
                {
                    Name        = myProductVM.Name,
                    Description = myProductVM.Description,
                    Price       = myProductVM.Price,
                    Department  = myDepartment
                };

                //Now we are going to save the brand new product and we are going to retrieve it with the id.

                ProductViewModel DbProductVM = _buisnessLogicClass.ConvertProductIntoVM(_buisnessLogicClass.CreateNewProduct(myProduct));
                return(View("Details", DbProductVM));
            }
            else
            {
                // Idk...
                return(BadRequest());
            }
        }