Beispiel #1
0
        public IHttpActionResult PutROUTE_NUM(decimal id, ROUTE_NUM rOUTE_NUM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.Accepted));
        }
Beispiel #2
0
        public IHttpActionResult GetROUTE_NUM(decimal id)
        {
            ROUTE_NUM rOUTE_NUM = db.ROUTE_NUM.Find(id);

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

            return(Ok(rOUTE_NUM));
        }
Beispiel #3
0
        public IHttpActionResult DeleteROUTE_NUM(decimal id)
        {
            ROUTE_NUM rOUTE_NUM = db.ROUTE_NUM.Find(id);

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

            db.ROUTE_NUM.Remove(rOUTE_NUM);
            db.SaveChanges();

            return(Ok(rOUTE_NUM));
        }
Beispiel #4
0
        public IHttpActionResult PostROUTE_NUM(ROUTE_NUM rOUTE_NUM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ROUTE_NUM.Add(rOUTE_NUM);

            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                    eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                        ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            catch (DbUpdateException)
            {
                if (ROUTE_NUMExists(rOUTE_NUM.ROUTE_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = rOUTE_NUM.ROUTE_ID }, rOUTE_NUM));
        }