Exemplo n.º 1
0
        public ActionResult Edit(About about, HttpPostedFileBase PostImage)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedName");

            if (ModelState.IsValid)
            {
                if (PostImage != null &&
                    (PostImage.ContentType == "image/jpeg" ||
                     PostImage.ContentType == "image/jpg" ||
                     PostImage.ContentType == "image/png"))
                {
                    string filename = $"about_{about.Id}.{PostImage.ContentType.Split('/')[1]}";

                    PostImage.SaveAs(Server.MapPath($"~/images/{filename}"));
                    about.AboutImage = filename;
                }
                BusinessLayerResult <About> res = aboutManager.UpdateAboutFoto(about);

                return(RedirectToAction("Index"));
            }
            return(View(about));
        }