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

            db.TipoLocacion.Add(tipoLocacion);
            await db.SaveChangesAsync();

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

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

            db.TipoLocacion.Remove(tipoLocacion);
            await db.SaveChangesAsync();

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

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

            TipoLocacion tipoLocacion = await db.TipoLocacion.FindAsync(key);

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

            patch.Put(tipoLocacion);

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

            return(Updated(tipoLocacion));
        }