コード例 #1
0
        public async Task <ActionResult <CheckList.Models.Task> > PostTask(CheckList.Models.Task task)
        {
            _db.Tasks.Add(task);
            await _db.SaveChangesAsync();

            return(CreatedAtAction("GetTask", new { id = task.ID }, task));
        }
コード例 #2
0
        public async Task <IActionResult> PutTask(Guid id, CheckList.Models.Task task)
        {
            if (id != task.ID)
            {
                return(BadRequest());
            }

            _db.Entry(task).State = EntityState.Modified;

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

            return(NoContent());
        }