예제 #1
0
 public void registrarEditorial()
 {
     Editorial e = new Editorial();
     e.Estado = 1;
     e.Nombre = "Editorial1";
     e.Pais = PaisBLL.Get(1);
     EditorialBLL.Create(e);
     Assert.AreNotEqual(0, e.Id);
 }
 public ActionResult Create(Editorial editorial)
 {
     try {
         EditorialBLL.Create(editorial);
         return RedirectToAction("Index");
     } catch(Exception ex) {
         return View("~/Views/Shared/Error.cshtml", new Models.ManejadorError(ex));
     }
 }
예제 #3
0
 public static void Create(Editorial editorial)
 {
     try {
         using(var ctx = new BibliotecaContext()) {
             editorial.Pais = ctx.Paises.Where(p => p.Id == editorial.Pais.Id).FirstOrDefault();
             ctx.Editoriales.AddObject(editorial);
             ctx.SaveChanges();
         }
     } catch(Exception ex) {
         throw new Exception("Ocurrio un error al obtener los datos, verifique la conexion con el servidor", ex);
     }
 }
예제 #4
0
        private void FixupEditorial(Editorial previousValue)
        {
            if (previousValue != null && previousValue.Libros.Contains(this))
            {
                previousValue.Libros.Remove(this);
            }

            if (Editorial != null)
            {
                if (!Editorial.Libros.Contains(this))
                {
                    Editorial.Libros.Add(this);
                }
            }
        }
예제 #5
0
 public static bool Delete(Editorial editorial)
 {
     return Delete(editorial.Id);
 }
예제 #6
0
 public static void Update(Editorial editorial)
 {
     try {
         using(var ctx = new BibliotecaContext()) {
             Editorial e1 = ctx.Editoriales.Where(e => e.Id == editorial.Id).FirstOrDefault();
             e1.Estado = editorial.Estado;
             e1.Nombre = editorial.Nombre;
             e1.Pais = ctx.Paises.Where(p => p.Id == editorial.Pais.Id).FirstOrDefault();
             ctx.SaveChanges();
         }
     } catch(Exception ex) {
         throw new Exception("Ocurrio un error al obtener los datos, verifique la conexion con el servidor", ex);
     }
 }
예제 #7
0
        private void FixupEditorial(Editorial previousValue)
        {
            if(previousValue != null && previousValue.Libros.Contains(this)) {
                previousValue.Libros.Remove(this);
            }

            if(Editorial != null) {
                if(!Editorial.Libros.Contains(this)) {
                    Editorial.Libros.Add(this);
                }
            }
        }
 public ActionResult Edit(int id, Editorial editorial)
 {
     try {
         editorial.Id = id;
         EditorialBLL.Update(editorial);
         return RedirectToAction("Index");
     } catch(Exception ex) {
         return View("~/Views/Shared/Error.cshtml", new Models.ManejadorError(ex));
     }
 }