public ActionResult AgregarNoticia(Noticias MiNoti, HttpPostedFileBase file) { if (!ModelState.IsValid) { try { if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Content/"), fileName); file.SaveAs(path); MiNoti.Foto = fileName; } } catch (Exception Error) { } FotosNoticias Mifoto = new FotosNoticias(); MiNoti.CargarNoticia(); Mifoto.Nombre = MiNoti.Foto; Mifoto.AgregarFoto(); Noticias UnaNoti = new Noticias(); List <Noticias> lista = UnaNoti.ListarNoticias(); ViewBag.ListarNoticias = lista; return(View("Index")); } else { return(View()); } }
public ActionResult AgregarNoticia(Noticias MiNoti) { //MiNoti.AgregarFoto(); MiNoti.CargarNoticia(); return(View("Index")); }