Exemplo n.º 1
0
        // POST: odata/mdSPanels
        public async Task <IHttpActionResult> Post(mdSPanel mdSPanel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.mdSPanels.Add(mdSPanel);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (mdSPanelExists(mdSPanel.PanelID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(mdSPanel));
        }
Exemplo n.º 2
0
        // DELETE: odata/mdSPanels(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] int key)
        {
            mdSPanel mdSPanel = await db.mdSPanels.FindAsync(key);

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

            db.mdSPanels.Remove(mdSPanel);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
        // PUT: odata/mdSPanels(5)
        public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <mdSPanel> patch)
        {
            Validate(patch.GetEntity());

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

            mdSPanel mdSPanel = await db.mdSPanels.FindAsync(key);

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

            patch.Put(mdSPanel);

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

            return(Updated(mdSPanel));
        }