Пример #1
0
        // PUT odata/StructureTypes(5)
        public async Task<IHttpActionResult> Put([FromODataUri] int key, StructureType structuretype)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (key != structuretype.StructureTypeId)
            {
                return BadRequest();
            }

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

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

            return Updated(structuretype);
        }
Пример #2
0
        // POST odata/StructureTypes
        public async Task<IHttpActionResult> Post(StructureType structuretype)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.StructureTypes.Add(structuretype);
            await db.SaveChangesAsync();

            return Created(structuretype);
        }