public IHttpActionResult Putalegria(long id, alegria alegria)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != alegria.idalegria)
            {
                return(BadRequest());
            }

            db.Entry(alegria).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!alegriaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult Getalegria(long id)
        {
            alegria alegria = db.alegria.Find(id);

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

            return(Ok(alegria));
        }
        public IHttpActionResult Postalegria(alegria alegria)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.alegria.Add(alegria);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = alegria.idalegria }, alegria));
        }
        public IHttpActionResult Deletealegria(long id)
        {
            alegria alegria = db.alegria.Find(id);

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

            db.alegria.Remove(alegria);
            db.SaveChanges();

            return(Ok(alegria));
        }