Exemple #1
0
        public async Task <IActionResult> PutTodoItem(long id, TodoItemDTO todoItemDTO)
        {
            if (id != todoItemDTO.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #2
0
 public void Update(Command entity)
 {
     using (var ctx = new DatabContext())
     {
         ctx.Commands.Attach(entity);
         ctx.Entry(entity).State = EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemple #3
0
 public virtual void Update(T entity)
 {
     dbset.Attach(entity);
     dataContext.Entry(entity).State = EntityState.Modified;
 }