예제 #1
0
        /// <summary>
        /// Updates task
        /// </summary>
        /// <param name="id"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public async Task <TaskModel> Update(int id, TaskModel entity)
        {
            using (TodoAppDbContext context = _contextFactory.CreateDbContext())
            {
                var editedEntity = context.Tasks.Where(e => e.Id == entity.Id).First();

                context.Entry(editedEntity).CurrentValues.SetValues(entity);

                await context.SaveChangesAsync();

                return(entity);
            }
        }
 public TEntity Update(TEntity entity)
 {
     _db.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     return(entity);
 }