Пример #1
0
        public IHttpActionResult Putinterests(decimal id, interests interests)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult Getinterests(decimal id)
        {
            interests interests = db.interests.Find(id);

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

            return(Ok(interests));
        }
Пример #3
0
        public IHttpActionResult Postinterests(interests interests)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.interests.Add(interests);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = interests.id }, interests));
        }
Пример #4
0
        public IHttpActionResult Deleteinterests(decimal id)
        {
            interests interests = db.interests.Find(id);

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

            db.interests.Remove(interests);
            db.SaveChanges();

            return(Ok(interests));
        }