예제 #1
0
        public IHttpActionResult PostOT_Master(OT_Master oT_Master)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.OT_Master.Add(oT_Master);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (OT_MasterExists(oT_Master.Id_OTMaster))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = oT_Master.Id_OTMaster }, oT_Master);
        }
예제 #2
0
        public IHttpActionResult PutOT_Master(int id, OT_Master oT_Master)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != oT_Master.Id_OTMaster)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }