コード例 #1
0
        public IHttpActionResult PutTimeTableRow(int id, TimeTableRow timeTableRow)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
        public IHttpActionResult PostTimeTableRow(TimeTableRow timeTableRow)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.timeTableRows.Add(timeTableRow);
            db.SaveChanges();

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