Example #1
0
        public ActionResult Edit(ProductViewModel prod, HttpPostedFileBase upload)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(prod));
            }

            _service.EditProduct(prod);

            if (upload != null)
            {
                string fileName = HttpContext.Server.MapPath(ConfigurationManager.AppSettings["ImageFolder"]) + prod.Image;
                if (System.IO.File.Exists(fileName))
                {
                    System.IO.File.Delete(fileName);
                }

                upload.SaveAs(fileName);
            }

            string path = HttpContext.Request.UrlReferrer.AbsolutePath;

            return(Content(path));
        }
Example #2
0
 public IHttpActionResult Put(ProductViewModel prod)
 {
     _service.EditProduct(prod);
     return(Ok());
 }