Example #1
0
        public IHttpActionResult PostdonArticle(donArticle donArticle)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.donArticles.Add(donArticle);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (donArticleExists(donArticle.IDarticleDon))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = donArticle.IDarticleDon }, donArticle));
        }
Example #2
0
        public IHttpActionResult PutdonArticle(int id, donArticle donArticle)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != donArticle.IDarticleDon)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public IHttpActionResult GetdonArticle(int id)
        {
            donArticle donArticle = db.donArticles.Find(id);

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

            return(Ok(donArticle));
        }
Example #4
0
        public IHttpActionResult DeletedonArticle(int id)
        {
            donArticle donArticle = db.donArticles.Find(id);

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

            db.donArticles.Remove(donArticle);
            db.SaveChanges();

            return(Ok(donArticle));
        }