public static SeccionRepository GetSeccionRepository() { if (mySeccionRepository == null) { mySeccionRepository = new SeccionRepository(); } return(mySeccionRepository); }
// GET: News/Edit/5 public ActionResult Edit(int id) { var nota = NewsRepository.GetNew(id); nota.Secciones = new SelectList(SeccionRepository.GetSecciones(), "SeccionID", "NombreSeccion"); nota.Categorias = new SelectList(CategoriaRepository.GetCategorias(), "CategoriaID", "NombreCategoria"); nota.Diarios = new SelectList(DiarioRepository.GetDiarios(), "DiarioID", "Nombre"); return(View(nota)); }
// GET: News/Create public ActionResult Create() { Nota nota = new Nota(); nota.Secciones = new SelectList(SeccionRepository.GetSecciones(), "SeccionID", "NombreSeccion"); nota.Categorias = new SelectList(CategoriaRepository.GetCategorias(), "CategoriaID", "NombreCategoria"); nota.Diarios = new SelectList(DiarioRepository.GetDiarios(), "DiarioID", "Nombre"); return(View(nota)); }
public ActionResult Delete(int id) { try { bool success = SeccionRepository.DeleteSeccion(id); if (success) { return(RedirectToAction("Index")); } else { return(View()); } } catch { return(View()); } }
public ActionResult Edit(int id, Seccion seccion) { try { bool success = SeccionRepository.UpdateSeccion(seccion); if (success) { return(RedirectToAction("Index")); } else { return(View()); } } catch (SqlException e) { System.Diagnostics.Debug.WriteLine(e.Message); return(View()); } }
public ActionResult Create(Seccion seccion) { try { // TODO: Add insert logic here bool success = SeccionRepository.InsertSeccion(seccion); if (success) { return(RedirectToAction("Index")); } else { return(View()); } } catch (SqlException e) { System.Diagnostics.Debug.WriteLine(e.Message); return(View()); } }
public ActionResult Create(Nota nota, HttpPostedFileBase file) { Nota nota2 = new Nota(); nota2.Secciones = new SelectList(SeccionRepository.GetSecciones(), "SeccionID", "NombreSeccion"); nota2.Categorias = new SelectList(CategoriaRepository.GetCategorias(), "CategoriaID", "NombreCategoria"); nota2.Diarios = new SelectList(DiarioRepository.GetDiarios(), "DiarioID", "Nombre"); if (ModelState.IsValid) { try { if (file.ContentLength > 0) { string filename = Path.GetFileName(file.FileName); string server_path = Path.Combine(Server.MapPath("~/Images"), filename); file.SaveAs(server_path); nota.Archivo = "~/Images/" + filename; } bool success = NewsRepository.InsertNota(nota); if (success) { return(RedirectToAction("Index")); } else { return(View()); } } catch (SqlException e) { System.Diagnostics.Debug.WriteLine(e.Message); return(View()); } } else { return(View(nota2)); } }
public SeccionBusiness(IUnitOfWork _unitOfWork) { unitOfWork = _unitOfWork; seccionRepository = new SeccionRepository(unitOfWork); }
// GET: Seccion/Details/5 public ActionResult Details(int id) { var secciones = SeccionRepository.GetSeccion(id); return(View(secciones)); }
// GET: Seccion public ActionResult Index() { var secciones = SeccionRepository.GetSecciones(); return(View(secciones)); }
// GET: Seccion/Delete/5 public ActionResult Delete(int?id) { var nota = SeccionRepository.GetSeccion(id); return(View(nota)); }
// GET: Seccion/Edit/5 public ActionResult Edit(int id) { var seccion = SeccionRepository.GetSeccion(id); return(View(seccion)); }