public ActionResult Create(PopUps popUps, HttpPostedFileBase PopUpImage) { ModelState.Remove("CreatedOnDatetime"); ModelState.Remove("ModifiedOnDatetime"); ModelState.Remove("ModifiedUsername"); if (ModelState.IsValid) { if (PopUpImage != null && (PopUpImage.ContentType == "image/jpeg" || PopUpImage.ContentType == "image/jpg" || PopUpImage.ContentType == "image/png")) { string filename = $"user_{popUps.Title}.{PopUpImage.ContentType.Split('/')[1]}"; PopUpImage.SaveAs(Server.MapPath($"~/Images/PopUpImage/{filename}")); popUps.PopUpImage = filename; } popUpManager.Insert(popUps); return(RedirectToAction("Index")); } return(View(popUps)); }