Пример #1
0
        public IHttpActionResult PutMRCorporate(int id, MRCorporate mRCorporate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult GetMRCorporate(int id)
        {
            MRCorporate mRCorporate = db.MRCorporates.Find(id);

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

            return(Ok(mRCorporate));
        }
Пример #3
0
        public IHttpActionResult DeleteMRCorporate(int id)
        {
            MRCorporate mRCorporate = db.MRCorporates.Find(id);

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

            db.MRCorporates.Remove(mRCorporate);
            db.SaveChanges();

            return(Ok(mRCorporate));
        }
Пример #4
0
        public IHttpActionResult PostMRCorporate(MRCorporate mRCorporate)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            var errors = ModelState.Values.SelectMany(v => v.Errors);

            db.MRCorporates.Add(mRCorporate);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = mRCorporate.ID }, mRCorporate));
        }