Пример #1
0
        public ActionResult Publish(int id)
        {
            ProductPublishVM publish = new ProductPublishVM();

            publish.datePublish = DateTime.Now;
            publish.ProductName = context.GetElement(id).ProductName;
            publish.ProdcutID   = id;
            return(View(publish));
        }
Пример #2
0
        public ActionResult Publish(ProductPublishVM publish)
        {
            if (ModelState.IsValid)
            {
                ProductPublish productPublish = new ProductPublish();
                productPublish.ProdcutID    = publish.ProdcutID;
                productPublish.ProductName  = publish.ProductName;
                productPublish.ProductPrice = publish.ProductPrice;
                productPublish.Description  = publish.Description;
                productPublish.datePublish  = publish.datePublish;

                context.AddProductPublish(productPublish);
                var product = context.GetElement(publish.ProdcutID.Value);
                return(RedirectToAction(nameof(Index), new { manhalID = product.ManhalId }));
            }
            return(View());
        }