public IHttpActionResult PutEditorials(long id, Editorials editorials) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != editorials.Id_Editorial) { return(BadRequest()); } db.Entry(editorials).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EditorialsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetEditorials(long id) { Editorials editorials = db.Editorials.Find(id); if (editorials == null) { return(NotFound()); } return(Ok(editorials)); }
public static string AddEditorial(DBNexosBook db, Editorials editorial) { if (editorial.Name == null || editorial.AddressMail == null) { return("Los datos no son correctos"); } if (editorial.MaxBooks == 0) { editorial.MaxBooks = -1; } editorial.CurrenBooks = 0; db.Editorials.Add(editorial); db.SaveChanges(); return("Editor registrado con exito"); }
public string PostEditorials(Editorials editorials) { string response; try { using (DBNexosBook db = new DBNexosBook()) { response = EditorialsDAL.AddEditorial(db, editorials); } } catch (Exception) { return("No se pudo hacer el registro, consulte a su administrador"); throw; } return(response); }