Exemplo n.º 1
0
 public static SeccionRepository GetSeccionRepository()
 {
     if (mySeccionRepository == null)
     {
         mySeccionRepository = new SeccionRepository();
     }
     return(mySeccionRepository);
 }
Exemplo n.º 2
0
        // 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));
        }
Exemplo n.º 3
0
        // 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));
        }
Exemplo n.º 4
0
 public ActionResult Delete(int id)
 {
     try
     {
         bool success = SeccionRepository.DeleteSeccion(id);
         if (success)
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 5
0
 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());
     }
 }
Exemplo n.º 6
0
 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());
     }
 }
Exemplo n.º 7
0
        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));
            }
        }
Exemplo n.º 8
0
 public SeccionBusiness(IUnitOfWork _unitOfWork)
 {
     unitOfWork        = _unitOfWork;
     seccionRepository = new SeccionRepository(unitOfWork);
 }
Exemplo n.º 9
0
        // GET: Seccion/Details/5
        public ActionResult Details(int id)
        {
            var secciones = SeccionRepository.GetSeccion(id);

            return(View(secciones));
        }
Exemplo n.º 10
0
        // GET: Seccion
        public ActionResult Index()
        {
            var secciones = SeccionRepository.GetSecciones();

            return(View(secciones));
        }
Exemplo n.º 11
0
        // GET: Seccion/Delete/5
        public ActionResult Delete(int?id)
        {
            var nota = SeccionRepository.GetSeccion(id);

            return(View(nota));
        }
Exemplo n.º 12
0
        // GET: Seccion/Edit/5
        public ActionResult Edit(int id)
        {
            var seccion = SeccionRepository.GetSeccion(id);

            return(View(seccion));
        }