コード例 #1
0
        // POST: odata/mdPanelSizes
        public async Task <IHttpActionResult> Post(mdPanelSize mdPanelSize)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.mdPanelSizes.Add(mdPanelSize);
            await db.SaveChangesAsync();

            return(Created(mdPanelSize));
        }
コード例 #2
0
        // DELETE: odata/mdPanelSizes(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] int key)
        {
            mdPanelSize mdPanelSize = await db.mdPanelSizes.FindAsync(key);

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

            db.mdPanelSizes.Remove(mdPanelSize);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        // PUT: odata/mdPanelSizes(5)
        public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <mdPanelSize> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            mdPanelSize mdPanelSize = await db.mdPanelSizes.FindAsync(key);

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

            patch.Put(mdPanelSize);

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

            return(Updated(mdPanelSize));
        }