Example #1
0
        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));
        }
Example #2
0
        public IHttpActionResult GetEditorials(long id)
        {
            Editorials editorials = db.Editorials.Find(id);

            if (editorials == null)
            {
                return(NotFound());
            }

            return(Ok(editorials));
        }
Example #3
0
        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");
        }
Example #4
0
        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);
        }