public ActionResult NewsForm(NewsUpload NewUp) { if (!ModelState.IsValid) { return(View("NewsForm", NewUp)); } var NewsIn = new News(); NewsIn.Header = NewUp.News.Header; NewsIn.Body = NewUp.News.Body; NewsIn.Date = DateTime.Now; if (NewUp.File != null) { string photoName = Path.GetFileName(NewUp.File.FileName); NewUp.File.SaveAs(Server.MapPath("/Images/News/" + photoName)); NewsIn.Photo = photoName; } _DBdata.News.Add(NewsIn); _DBdata.SaveChanges(); return(RedirectToAction("NewsList", "Operator")); }
public ActionResult AddNews() { var NewUp = new NewsUpload(); return(View("NewsForm", NewUp)); }