コード例 #1
0
        public async Task <ActionResult <SleepingTime> > PostSleepingTime(SleepingTime sleepingTime)
        {
            _context.SleepingTime.Add(sleepingTime);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSleepingTime", new { id = sleepingTime.Id }, sleepingTime));
        }
コード例 #2
0
        public async Task <IActionResult> PutSleepingTime(int id, SleepingTime sleepingTime)
        {
            if (id != sleepingTime.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }