Exemplo n.º 1
0
        public IHttpActionResult PostSpecialIntrest(SpecialIntrest specialIntrest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SpecialIntrests.Add(specialIntrest);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (SpecialIntrestExists(specialIntrest.IntrestCode))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = specialIntrest.IntrestCode }, specialIntrest));
        }
Exemplo n.º 2
0
        public IHttpActionResult PutSpecialIntrest(string id, SpecialIntrest specialIntrest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
        public IHttpActionResult GetSpecialIntrest(string id)
        {
            SpecialIntrest specialIntrest = db.SpecialIntrests.Find(id);

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

            return(Ok(specialIntrest));
        }
Exemplo n.º 4
0
        public IHttpActionResult DeleteSpecialIntrest(string id)
        {
            SpecialIntrest specialIntrest = db.SpecialIntrests.Find(id);

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

            db.SpecialIntrests.Remove(specialIntrest);
            db.SaveChanges();

            return(Ok(specialIntrest));
        }