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)); } }
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); } }
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 static bool Delete(Editorial editorial) { return Delete(editorial.Id); }
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); } }
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)); } }