// POST: odata/LegoLibraries
        public IHttpActionResult Post(LegoLibrary legoLibrary)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.LegoLibraries.Add(legoLibrary);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (LegoLibraryExists(legoLibrary.LegoID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(legoLibrary));
        }
        // DELETE: odata/LegoLibraries(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            LegoLibrary legoLibrary = db.LegoLibraries.Find(key);

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

            db.LegoLibraries.Remove(legoLibrary);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
        // PUT: odata/LegoLibraries(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <LegoLibrary> patch)
        {
            Validate(patch.GetEntity());

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

            LegoLibrary legoLibrary = db.LegoLibraries.Find(key);

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

            patch.Put(legoLibrary);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LegoLibraryExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(legoLibrary));
        }