Esempio n. 1
0
 public static void Create(Pais pais)
 {
     using(var ctx = new BibliotecaContext()) {
         if(ctx.Paises.Where(p => p.Nombre == pais.Nombre).Count() > 0)
             throw new Excepcion("Ya existe un País con el nombre '" + pais.Nombre + "'");
         ctx.Paises.AddObject(pais);
         ctx.SaveChanges();
     }
 }
Esempio n. 2
0
        public void registrarPais()
        {
            Pais p = new Pais();
            p.Nombre = "Bolivia";
            p.Gentilicio = "Boliviana";
            p.Estado = 1;
            BLL.PaisBLL.Create(p);

            Assert.AreNotEqual(0, p.Id);
        }
 public ActionResult Create(Pais pais)
 {
     try {
         PaisBLL.Create(pais);
         return RedirectToAction("Index");
     } catch(Excepcion ec) {
         ViewBag.mensaje = new Models.Mensaje(ec.CreateMensaje(), Models.Mensaje.TipoMsg.error);
         return View("Create", pais);
     } catch(Exception ex) {
         return View("~/Views/Shared/Error.cshtml", new Models.ManejadorError(ex));
     }
 }
Esempio n. 4
0
 public static void Update(Pais pais)
 {
     using(var ctx = new BibliotecaContext()) {
         Pais p1 = ctx.Paises.Where(p => p.Nombre == pais.Nombre).FirstOrDefault();
         if(p1 != null && p1.Id != pais.Id)
             throw new Excepcion("Ya existe un País con el nombre '" + pais.Nombre + "'");
         p1 = ctx.Paises.Where(p => p.Id == pais.Id).FirstOrDefault();
         p1.Estado = pais.Estado;
         p1.Gentilicio = pais.Gentilicio;
         p1.Nombre = pais.Nombre;
         ctx.SaveChanges();
     }
 }
Esempio n. 5
0
 public void CreateTest()
 {
     //  Autor autor = null; // TODO: Inicializar en un valor adecuado
     Autor a = new Autor();
     a.Nombres="pablo";
     a.Apellidos= "pablo";
         Pais p = new Pais();
         p.Nombre = "Bolivia";
         p.Gentilicio = "Boliviana";
         p.Estado = 1;
         a.Pais = p;
     a.Estado = 1;
     AutorBLL.Create(a);
        // Assert.Inconclusive("Un método que no devuelve ningún valor no se puede comprobar.");
 }
Esempio n. 6
0
        private void FixupPais(Pais previousValue)
        {
            if(previousValue != null && previousValue.Editoriales.Contains(this)) {
                previousValue.Editoriales.Remove(this);
            }

            if(Pais != null) {
                if(!Pais.Editoriales.Contains(this)) {
                    Pais.Editoriales.Add(this);
                }
            }
        }
 public ActionResult Edit(int id, Pais pais)
 {
     try {
         pais.Id = id;
         PaisBLL.Update(pais);
         return RedirectToAction("Index");
     } catch(Excepcion ec) {
         ViewBag.mensaje = new Models.Mensaje(ec.UpdateMensaje(), Models.Mensaje.TipoMsg.error);
         return View("Edit", pais);
     } catch(Exception ex) {
         return View("~/Views/Shared/Error.cshtml", new Models.ManejadorError(ex));
     }
 }
Esempio n. 8
0
 public static void Delete(Pais pais)
 {
     Delete(pais.Id);
 }