コード例 #1
0
        public IActionResult RemoveSpecificationFilePdf(long id, HardwareViewModel hardwareViewModel, [Bind("ProductID,ProductTypeID,Name,Description,StatusID,InfoUrl,SpecificationFile")] Hardware hardware)
        {
            if (id != hardware.ProductID)
            {
                return(NotFound());
            }

            Tuple <string, string, bool> removePDF = service.RemoveSpecificationFilePdf(hardwareViewModel.hardware.ProductID);

            hardware.SpecificationFileName = "";
            hardware.SpecificationFilePath = "";
            hardware.HasFile = false;

            ModelState.Clear();
            TryValidateModel(hardware);

            if (ModelState.IsValid)
            {
                try
                {
                    service.Update(hardware);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HardwareExists(hardware.ProductID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction(nameof(Index));
                //return RedirectToAction("Edit", "Hardware", new { id = hardware.ProductID });
            }

            return(RedirectToAction("Edit", "Hardware", new { id = hardware.ProductID }));
        }