public IActionResult Edit(int id)
        {
            ViewBag.productId = new SelectList(_iadmin.ShowProduct(), "Id", "Name");
            ProductDownloadFile proedit = _iadmin.ShowProductDownloadFileById(id);

            return(View(proedit));
        }
        public IActionResult UpdateDownloadFiles(int id)
        {
            ProductDownloadFile PD = _itemp.ShowDownloadFileById(id);

            _itemp.UpdateDownloadNumber(id);
            return(Redirect(PD.RouteAddress));
        }
        public IActionResult Create(ProductDownloadFile pro)
        {
            //if (ModelState.IsValid)
            //{
            ProductDownloadFile newpro = new ProductDownloadFile()
            {
                ProductId      = pro.ProductId,
                Name           = pro.Name,
                AuthorName     = pro.AuthorName,
                TypeName       = pro.TypeName,
                FileFormat     = pro.FileFormat,
                BlogLang       = pro.BlogLang,
                SourceName     = pro.SourceName,
                RouteAddress   = pro.RouteAddress,
                Volume         = pro.Volume,
                NumberDownload = 0
            };

            _iadmin.AddProductDownloadFile(newpro);
            return(RedirectToAction("Index"));
            //}
            //else
            //{
            //    ViewBag.productId = new SelectList(_iadmin.ShowProduct(), "Id", "Name");
            //    return View(pro);
            //}
        }
Example #4
0
        public void UpdateDownloadNumber(int id)
        {
            ProductDownloadFile PD = _context.ProductDownloadFiles.Find(id);

            PD.NumberDownload += 1;
            _context.SaveChanges();
        }
        public bool UpdateProductDownloadFile(int id, int productId, string name, string authorName, string typeName, string fileFormat, string blogLang, string sourceName, string routeAddress, string volume)
        {
            ProductDownloadFile pro = _context.ProductDownloadFiles.Find(id);

            if (pro != null)
            {
                pro.ProductId    = productId;
                pro.Name         = name;
                pro.AuthorName   = authorName;
                pro.TypeName     = typeName;
                pro.FileFormat   = fileFormat;
                pro.BlogLang     = blogLang;
                pro.SourceName   = sourceName;
                pro.RouteAddress = routeAddress;
                pro.Volume       = volume;

                _context.SaveChanges();
                return(true);
            }
            else

            {
                return(false);
            }
        }
        public IActionResult Edit(int id, ProductDownloadFile pro)
        {
            //if (ModelState.IsValid)
            //{
            bool isedit = _iadmin.UpdateProductDownloadFile(id, pro.ProductId, pro.Name, pro.AuthorName, pro.TypeName, pro.FileFormat, pro.BlogLang, pro.SourceName, pro.RouteAddress, pro.Volume);

            if (isedit)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(pro));
            }
            //}
            //ViewBag.productId = new SelectList(_iadmin.ShowProduct(), "Id", "Name");
            //return View(pro);
        }
 public int AddProductDownloadFile(ProductDownloadFile productDownloadFile)
 {
     _context.ProductDownloadFiles.Add(productDownloadFile);
     _context.SaveChanges();
     return(productDownloadFile.Id);
 }