Beispiel #1
0
        // PUT odata/DigitalContainers(5)
        public IHttpActionResult Put([FromODataUri] long key, DigitalContainer container)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (key != container.Id)
            {
                return(BadRequest());
            }

            db.Entry(container).State = EntityState.Modified;

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

            return(Updated(container));
        }
Beispiel #2
0
        // POST odata/DigitalContainers
        public IHttpActionResult Post(DigitalContainer container)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Containers.Add(container);
            db.SaveChanges();

            return(Created(container));
        }