//// GET: ProductDetails
        //public ActionResult Index()
        //{
        //    var products = _context.ProductDetails.ToList();
        //    return View(products);
        //}

        //public ActionResult Details(int id)
        //{
        //    var singleProduct = _context.ProductDetails.SingleOrDefault(k => k.ProductId == id);
        //    if (singleProduct == null)
        //        return HttpNotFound();
        //    return View(singleProduct);
        //}

        //public ActionResult Update(int? id)
        //{
        //    var updateProduct = _context.ProductDetails.SingleOrDefault(c => c.ProductId == id);
        //    if (updateProduct == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    var up = new ProDetailsAndCatagory
        //    {
        //        ProductDetail = updateProduct,
        //        Catagories = _context.Categories.ToList()
        //    };
        //    return View("Create", up);
        //}

        public ActionResult Create()
        {
            var newCatagory = _context.Categories.ToList();
            var viewModel   = new ProDetailsAndCatagory
            {
                Catagories = newCatagory
                             //ProductDetail = new ProductDetail()
            };

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public ActionResult Update(int?id)
        {
            var updateProduct = _context.ProductDetails.SingleOrDefault(c => c.ProductId == id);

            if (updateProduct == null)
            {
                return(HttpNotFound());
            }
            var up = new ProDetailsAndCatagory
            {
                ProductDetail = updateProduct,
                Catagories    = _context.Catagories.ToList()
            };

            return(View("Create", up));
        }
        public ActionResult Create(ProDetailsAndCatagory product)
        {
            //productObj.ProductName = Request.Form["ProductName"];
            //productObj.ShortDescription = Request.Form["ShortDescription"];
            //productObj.Price = Convert.ToInt32( Request.Form["Price"]);
            //productObj.LongDescription = Request.Form["LongDescription"];
            //productObj.ImagePath = Request.Form["ImagePath"];
            //productObj.CatagoryId  = Convert.ToInt32(Request.Form["CatagoryId"]);


            productObj.ProductName      = product.ProductDetail.ProductName;
            productObj.ShortDescription = product.ProductDetail.ShortDescription;
            productObj.LongDescription  = product.ProductDetail.LongDescription;
            productObj.Price            = product.ProductDetail.Price;
            productObj.CatagoryId       = product.ProductDetail.CatagoryId;
            productObj.ImagePath        = product.ProductDetail.ImagePath;

            _context.ProductDetails.Add(productObj);                      // Data Binding

            _context.SaveChanges();

            return(RedirectToAction("Index", "ProductDetails"));
        }