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

            db.ElasticSlvPinCouplings.Add(elasticSlvPinCoup);

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

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

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }