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

            db.BikeContainer.Add(bikeContainer);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (BikeContainerExists(bikeContainer.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

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

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

            db.BikeContainer.Remove(bikeContainer);
            await db.SaveChangesAsync();

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

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

            BikeContainer bikeContainer = await db.BikeContainer.FindAsync(key);

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

            patch.Put(bikeContainer);

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

            return(Updated(bikeContainer));
        }
Exemplo n.º 4
0
 public void GetListItem(BikeContainer item)
 {
     ActiveItem = item;
 }
Exemplo n.º 5
0
 public void AddContainer(BikeContainer container)
 {
     BikeContainers.Add(container);
 }