public override async Task<Setting> UpdateAsync(Setting setting) { // Update setting var localSetting = context.Set<Setting>().Local.FirstOrDefault(s => s.Id == setting.Id); if (localSetting != null) { context.Entry(localSetting).State = EntityState.Detached; } context.Entry(setting).State = EntityState.Modified; // Update filetype foreach (FileType fileType in setting.FileTypes) { var localFileType = context.Set<FileType>().Local.FirstOrDefault(f => f.Id == fileType.Id); if (localFileType != null) { context.Entry(localFileType).State = EntityState.Detached; } context.Entry(fileType).State = EntityState.Modified; } await SaveAsync(); return setting; }
public override async Task <FileSize> UpdateAsync(FileSize fileSize) { // Update FileSize var localFileSize = context.Set <FileSize>().Local.FirstOrDefault(f => f.Id == fileSize.Id); if (localFileSize != null) { context.Entry(localFileSize).State = EntityState.Detached; } context.Entry(fileSize).State = EntityState.Modified; await SaveAsync(); return(fileSize); }
/// <summary> /// Update entity in database async /// </summary> /// <param name="model"></param> /// <returns>T</returns> public virtual async Task <T> UpdateAsync(T model) { context.Entry(model).State = EntityState.Modified; await SaveAsync(); return(model); }
public override async Task <Filter> UpdateAsync(Filter filter) { // Update setting var localFilter = context.Set <Filter>().Local.FirstOrDefault(f => f.Id == filter.Id); if (localFilter != null) { context.Entry(localFilter).State = EntityState.Detached; } context.Entry(filter).State = EntityState.Modified; await SaveAsync(); return(filter); }
public async Task <List <Movie> > UpdateAllMovieAsync(List <Movie> movies) { foreach (Movie movie in movies) { Movie localMovie = context.Set <Movie>().Local.FirstOrDefault(m => m.Id == movie.Id); if (localMovie != null) { context.Entry(localMovie).State = EntityState.Detached; } context.Entry(movie).State = EntityState.Modified; } await SaveAsync(); return(movies); }