Пример #1
0
        public async Task<IHttpActionResult> PostSrvDriverReactor(SrvDriverReactor srvDriverReactor)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.SrvDriverReactors.Add(srvDriverReactor);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (SrvDriverReactorExists(srvDriverReactor.TypeID))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = srvDriverReactor.TypeID }, srvDriverReactor);
        }
Пример #2
0
        public async Task<IHttpActionResult> PutSrvDriverReactor(string id, SrvDriverReactor srvDriverReactor)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != srvDriverReactor.TypeID)
            {
                return BadRequest();
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SrvDriverReactorExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }