示例#1
0
        // POST: odata/Geographies
        public IHttpActionResult Post(DimGeography dimGeography)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DimGeographies.Add(dimGeography);
            db.SaveChanges();

            return(Created(dimGeography));
        }
示例#2
0
        // DELETE: odata/Geographies(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            DimGeography dimGeography = db.DimGeographies.Find(key);

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

            db.DimGeographies.Remove(dimGeography);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#3
0
        // PUT: odata/Geographies(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <DimGeography> patch)
        {
            Validate(patch.GetInstance());

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

            DimGeography dimGeography = db.DimGeographies.Find(key);

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

            patch.Put(dimGeography);

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

            return(Updated(dimGeography));
        }