コード例 #1
0
        // PUT: odata/BenthicEventConditions(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <BenthicEventCondition> patch)
        {
            Validate(patch.GetEntity());

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

            BenthicEventCondition benthicEventCondition = db.BenthicEventConditions.Find(key);

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

            BenthicEvent @BenthicEvent = db.BenthicEvents.Find(benthicEventCondition.Id);
            var          check         = AuthorizeLogic.VerifyBenthicEventEditPermission(@BenthicEvent);

            if (check)
            {
                patch.Put(benthicEventCondition);

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

                return(Updated(benthicEventCondition));
            }
            else
            {
                return(Unauthorized());
            }
        }
コード例 #2
0
        // POST: odata/BenthicSamples
        public IHttpActionResult Post(BenthicSample benthicSample)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            BenthicEvent @BenthicEvent = db.BenthicEvents.Find(benthicSample.BenthicEventId);
            var check = AuthorizeLogic.VerifyBenthicEventEditPermission(@BenthicEvent);

            if (check)
            {
                db.BenthicSamples.Add(benthicSample);
                db.SaveChanges();

                return Created(benthicSample);
            }
            else
            {
                return Unauthorized();
            }
        }
コード例 #3
0
        // POST: odata/BenthicEvents
        public IHttpActionResult Post(BenthicEvent benthicEvent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var check = AuthorizeLogic.VerifyBenthicEventEditPermission(benthicEvent);

            if (check)
            {
                db.BenthicEvents.Add(benthicEvent);
                db.SaveChanges();

                return(Created(benthicEvent));
            }
            else
            {
                return(Unauthorized());
            }
        }
コード例 #4
0
        // DELETE: odata/BenthicSamples(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            BenthicSample benthicSample = db.BenthicSamples.Find(key);
            if (benthicSample == null)
            {
                return NotFound();
            }
            BenthicEvent @BenthicEvent = db.BenthicEvents.Find(benthicSample.BenthicEventId);
            var check = AuthorizeLogic.VerifyBenthicEventEditPermission(@BenthicEvent);

            if (check)
            {
                db.BenthicSamples.Remove(benthicSample);
                db.SaveChanges();

                return StatusCode(HttpStatusCode.NoContent);
            }
            else
            {
                return Unauthorized();
            }
        }