public async Task Update(params DirectoryModel[] directories) { foreach (var directory in directories) { var dirInDb = await _directoryRepository.GetByIdWithTracking(directory.Id); if (!string.IsNullOrWhiteSpace(directory.Name)) { dirInDb.Name = directory.Name; } dirInDb.Private = directory.Private; dirInDb.StaffOnly = directory.StaffOnly; // Cannot move root directories or remove parent from child directories if (dirInDb.ParentId != null && directory.ParentId != null) { dirInDb.ParentId = directory.ParentId; } } await _directoryRepository.SaveChanges(); }