コード例 #1
0
        public async Task <ActionResult <EducationalRecord> > PostEducationalRecord(EducationalRecord educationalRecord)
        {
            _context.EducationalRecords.Add(educationalRecord);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEducationalRecord", new { id = educationalRecord.Id }, educationalRecord));
        }
コード例 #2
0
        public async Task <IActionResult> PutEducationalRecord(int id, EducationalRecord educationalRecord)
        {
            if (id != educationalRecord.Id)
            {
                return(BadRequest());
            }

            _context.Entry(educationalRecord).State = EntityState.Modified;

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

            return(NoContent());
        }