public static void EnsurePopulated() { using (MySQLContext db = new MySQLContext()) { //db.Database.EnsureDeleted(); db.Database.EnsureCreated(); } }
public Accomodation GetAccomodationAndCulturalExchangeList(Guid id) { using (var db = new MySQLContext(_OptionsBuilder)) { return(db.Accomodation.Include(x => x.CulturalExchanges) .FirstOrDefault(x => x.Id == id)); } }
public SystemEnvironment GetEnvironmentByIdIncludeDependencys(Guid id) { using (var db = new MySQLContext(_OptionsBuilder)) { return(db.Environment.Include(x => x.Students) .Include(x => x.CulturalExchange) .Include(x => x.Accomodations).FirstOrDefault(x => x.Id == id)); } }
public MedicalController(MySQLContext context, BlockchainService service, IHostingEnvironment hostingEnvironment) { _context = context; _hostingEnvironment = hostingEnvironment; _blockchainService = service; _blockchainService.Initialize(); }
public TEntity Update(TEntity obj) { using (var db = new MySQLContext(_OptionsBuilder)) { var entity = db.Set <TEntity>().Update(obj); db.SaveChanges(); return(entity.Entity); } }
public void Update(MySQLContext db) { var scan = db.Scans.FirstOrDefault(s => s.FolderPath == FolderPath); if (scan != null) { scan.LastScanned = LastScanned; db.SaveChanges(); } }
public bool Exists() { bool exists = false; using (MySQLContext db = new MySQLContext(Logger)) { exists = db.Albums.Any(a => a.FolderPath == FolderPath); } return(exists); }
public ReceivePaymentCulturalExchange GetByIdIncludedDependency(Guid id) { using (var db = new MySQLContext(_OptionsBuilder)) { return(db.Set <ReceivePaymentCulturalExchange>() .Include(x => x.Environment) .Include(x => x.CulturalExchange) .ThenInclude(x => x.Student) .FirstOrDefault(x => x.Id == id)); } }
public bool Exists() { bool exists = false; using (MySQLContext db = new MySQLContext(Logger)) { exists = db.MediaFiles.Any(a => a.FilePath == FilePath); } return(exists); }
public List <ReceivePaymentCulturalExchange> GetAllIncludedDependencys(Guid environmentId) { using (var db = new MySQLContext(_OptionsBuilder)) { return(db.Set <ReceivePaymentCulturalExchange>() .Include(x => x.Environment) .Include(x => x.CulturalExchange) .ThenInclude(x => x.Student) .ToList()); } }
public void Add(MySQLContext db) { Data.Tables.Scans scan = new Data.Tables.Scans() { FolderPath = FolderPath, LastScanned = LastScanned }; db.Scans.Add(scan); db.SaveChanges(); }
public TEntity Insert(TEntity obj) { using (var db = new MySQLContext(_OptionsBuilder)) { db.Entry(obj).State = EntityState.Added; var entity = db.Set <TEntity>().Add(obj); db.SaveChanges(); return(entity.Entity); } }
private void LoadAlbumDetails(string albumDirectory, int retry = 0) { try { AlbumDetailed album = null; using (MySQLContext db = new MySQLContext(Logger)) { if (Globals.VerboseLogging) { Logger.Info($"Loading album details for '{albumDirectory}'."); } var baseAlbum = db.Albums.FirstOrDefault(a => a.FolderPath == albumDirectory); if (baseAlbum == null) { throw new Exception($"Could not locate album entry for '{albumDirectory}'."); } album = GetAlbumDetails(baseAlbum, db); baseAlbum = null; if (Globals.VerboseLogging) { Logger.Info($"Caching '{albumDirectory}' details."); } } AlbumDictionary[albumDirectory] = album; AlbumsChecked++; if (AlbumsChecked % int.Parse(ConfigurationManager.AppSettings["ProcessUpdateCounter"] ?? "100") == 0) { Logger.Info($"Checked {AlbumsChecked} albums..."); } } catch (Exception ex) { if (retry < 3) { retry++; Logger.Info($"Error loading album information: {albumDirectory}. Retrying {retry} of 3..."); LoadAlbumDetails(albumDirectory, retry); } else { Logger.Error($"Error loading album information: {albumDirectory}", ex); } } }
public List <ReceivePaymentCulturalExchange> GetAllIncludedDependencysByCulturalExchangeId(Guid culturalExchangeId) { using (var db = new MySQLContext(_OptionsBuilder)) { return(db.Set <ReceivePaymentCulturalExchange>() .Include(x => x.Environment) .Include(x => x.CulturalExchange) .ThenInclude(x => x.Student) .Include(x => x.CulturalExchange.College) .ThenInclude(col => col.CollegeTime) .Where(x => x.CulturalExchangeId == culturalExchangeId) .ToList()); } }
public void Add(MySQLContext db) { Data.Tables.Albums album = new Data.Tables.Albums() { Album = AlbumName, AlbumArtist = AlbumArtist, Discs = TotalDiscs, Disc = DiscNumber, FolderPath = FolderPath, Year = Year, LastScanned = DateTime.Now }; db.Albums.Add(album); db.SaveChanges(); }
public void Update(MySQLContext db) { var album = db.Albums.FirstOrDefault(a => a.FolderPath == FolderPath); if (album != null) { album.FolderPath = FolderPath; album.Album = AlbumName; album.AlbumArtist = AlbumArtist; album.Discs = TotalDiscs; album.Disc = DiscNumber; album.Year = Year; album.LastScanned = DateTime.Now; db.SaveChanges(); } }
public void CheckForErrors() { Logger.Info($"Checking for tag errors..."); FilesChecked = 0; AlbumsChecked = 0; ScanStart = DateTime.Now; using (MySQLContext db = new MySQLContext(Logger)) { foreach (var mediaFile in db.MediaFiles) { var albumDirectory = Path.GetDirectoryName(mediaFile.FilePath) + "\\"; if (!AlbumDictionary.ContainsKey(albumDirectory)) { AlbumDictionary[albumDirectory] = null; AlbumActions.Add(() => LoadAlbumDetails(albumDirectory)); } TagActions.Add(() => CheckTagDetails(mediaFile)); } } if (!string.IsNullOrEmpty(ParallelThreads)) { Logger.Info($"Running with maximum number of threads: {ParallelThreads}."); var tagOptions = new ParallelOptions { MaxDegreeOfParallelism = int.Parse(ParallelThreads) }; Logger.Info($"Loading album information."); Parallel.Invoke(tagOptions, AlbumActions.ToArray()); Logger.Info($"Checking tag data."); Parallel.Invoke(tagOptions, TagActions.ToArray()); } else { Parallel.Invoke(AlbumActions.ToArray()); Parallel.Invoke(TagActions.ToArray()); } ScanEnd = DateTime.Now; }
public PersonServiceImpl(MySQLContext context) { mySQLContext = context; if (mySQLContext.Persons.Count() == 0) { mySQLContext.Persons.AddRange( new Person { FirstName = "Maria Vilma", LastName = "Louzada", Address = "110 Norte, Al. 25, Lote 2", Gender = "Feminine" }, new Person { FirstName = "ANITA VAITEROSKI", LastName = "DE LIMA", Address = "Rua Armando Salles de Oliveira", Gender = "Feminine" }, new Person { FirstName = "GUILHERME HENRIQUE", LastName = "BARBOSA DE MATOS", Address = "Avenida Maranhão", Gender = "Male" }, new Person { FirstName = "JOSLEI ELISEU", LastName = "LIEBL", Address = "Rua Adolfo Konder", Gender = "Male" }, new Person { FirstName = "LUCAS ALEF SOUZA", LastName = "DA SILVA", Address = "Avenida Curuá-Una", Gender = "Male" }); mySQLContext.SaveChanges(); } }
public void AddOrUpdate() { if (!TagDataLoaded) { Logger.Info($"Tag data not loaded for file '{FilePath}'."); return; } DateTime processStart = DateTime.Now; using (var db = new MySQLContext(Logger)) { if (!Exists(db)) { if (Globals.VerboseLogging) { Logger.Info($"Adding new entry for file '{FilePath}'."); } Add(db); } else { if (Globals.VerboseLogging) { Logger.Info($"Updating entry for file '{FilePath}'."); } Update(db); } } DateTime processEnd = DateTime.Now; if (Globals.VerboseLogging) { Logger.Info($"'{FilePath}' AddOrUpdate completed in {(processEnd - processStart).TotalMilliseconds} milliseconds."); } }
public BaseContext CreateReplicaDbContext(LoginModel model) { String replicaConnectionString; BaseContext replicaDBContext; switch (model.ReplicaServerType) { case DatabaseConstants.SQL_SERVER: replicaConnectionString = SQLConnectionString.Replace("{server}", model.ReplicaServerName).Replace("{database}", model.ReplicaDatabaseName).Replace("{user id}", model.ReplicaUserName).Replace("{password}", model.ReplicaPassword); replicaDBContext = new SQLContext(replicaConnectionString); break; case DatabaseConstants.MY_SQL: replicaConnectionString = MySQLConnectionString.Replace("{server}", model.ReplicaServerName).Replace("{database}", model.ReplicaDatabaseName).Replace("{user id}", model.ReplicaUserName).Replace("{password}", model.ReplicaPassword); replicaDBContext = new MySQLContext(replicaConnectionString); break; default: replicaConnectionString = SQLConnectionString.Replace("{server}", model.ReplicaServerName).Replace("{database}", model.ReplicaDatabaseName).Replace("{user id}", model.ReplicaUserName).Replace("{password}", model.ReplicaPassword); replicaDBContext = new SQLContext(replicaConnectionString); break; } return(replicaDBContext); }
public BaseContext CreateDbContext(LoginModel model) { String primaryConnectionString; BaseContext primaryDBContext; switch (model.PrimaryServerType) { case DatabaseConstants.SQL_SERVER: primaryConnectionString = SQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword); primaryDBContext = new SQLContext(primaryConnectionString); break; case DatabaseConstants.MY_SQL: primaryConnectionString = MySQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword); primaryDBContext = new MySQLContext(primaryConnectionString); break; default: primaryConnectionString = SQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword); primaryDBContext = new SQLContext(primaryConnectionString); break; } return(primaryDBContext); }
public void AddOrUpdate() { using (var db = new MySQLContext(Logger)) { if (!Exists(db)) { if (Globals.VerboseLogging) { Logger.Info($"Adding new entry for scan of '{FolderPath}'."); } Add(db); } else { if (Globals.VerboseLogging) { Logger.Info($"Updating entry for scan of '{FolderPath}'."); } Update(db); } } }
public GroupService(MySQLContext mySQLContext) { _mySQLContext = mySQLContext; _converter = new GroupConverter(); }
public UserRepository(MySQLContext context) { _context = context; }
public PersonServiceImpl(MySQLContext mySQLContext) { _context = mySQLContext; }
public WebUserRepositoryImpl(MySQLContext context) { _context = context; }
public HomeworkRepository(MySQLContext db) { this.db = db; }
public PersonRepositoryImpl(MySQLContext context) { _context = context; }
public GenericRepository(MySQLContext context) { _context = context; dataset = _context.Set <T>(); }
public PersonServiceImplementation(MySQLContext context) { //Context injection _contex = context; }
public MysqlDBManager() { this.context = new MySQLContext(); }