예제 #1
0
        public async Task <IActionResult> PutToDo(int id, ToDo toDo)
        {
            if (id != toDo.Id)
            {
                return(BadRequest());
            }

            try
            {
                var obj = _context.Find <ToDo>(id);
                obj.Description = toDo.Description;
                obj.IsComplete  = toDo.IsComplete;
                obj.Priority    = toDo.Priority;
                obj.userEmail   = await Email();

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

            return(Accepted());
        }
예제 #2
0
        public IActionResult GetById(long id)
        {
            var item = _context.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(Ok(item));
        }