Esempio n. 1
0
        public IHttpActionResult PostJusInterest(JusInterest jusInterest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.JusInterests.Add(jusInterest);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (JusInterestExists(jusInterest.InterestCode))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = jusInterest.InterestCode }, jusInterest));
        }
Esempio n. 2
0
        public IHttpActionResult PutJusInterest(string id, JusInterest jusInterest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public IHttpActionResult GetJusInterest(string id)
        {
            JusInterest jusInterest = db.JusInterests.Find(id);

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

            return(Ok(jusInterest));
        }
Esempio n. 4
0
        public IHttpActionResult DeleteJusInterest(string id)
        {
            JusInterest jusInterest = db.JusInterests.Find(id);

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

            db.JusInterests.Remove(jusInterest);
            db.SaveChanges();

            return(Ok(jusInterest));
        }