コード例 #1
0
        public async Task<IHttpActionResult> PutResourceHistory(long id, ResourceHistory resourceHistory)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != resourceHistory.AuditId)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
        // POST: odata/ResourceHistories
        public async Task<IHttpActionResult> Post(ResourceHistory resourceHistory)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.ResourceHistory.Add(resourceHistory);
            await db.SaveChangesAsync();

            return Created(resourceHistory);
        }
コード例 #3
0
        public async Task<IHttpActionResult> PostResourceHistory(ResourceHistory resourceHistory)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.ResourceHistory.Add(resourceHistory);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = resourceHistory.AuditId }, resourceHistory);
        }