Beispiel #1
0
        public IHttpActionResult PostReasonClosed(ReasonClosed reasonClosed)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ReasonCloseds.Add(reasonClosed);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (ReasonClosedExists(reasonClosed.ReasonIfClosed))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = reasonClosed.ReasonIfClosed }, reasonClosed));
        }
Beispiel #2
0
        public IHttpActionResult PutReasonClosed(string id, ReasonClosed reasonClosed)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public IHttpActionResult GetReasonClosed(string id)
        {
            ReasonClosed reasonClosed = db.ReasonCloseds.Find(id);

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

            return(Ok(reasonClosed));
        }
Beispiel #4
0
        public IHttpActionResult DeleteReasonClosed(string id)
        {
            ReasonClosed reasonClosed = db.ReasonCloseds.Find(id);

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

            db.ReasonCloseds.Remove(reasonClosed);
            db.SaveChanges();

            return(Ok(reasonClosed));
        }