public OSTicketService(string databaseServer, string databaseUsername, string databasePassword, string databaseName, IOSTicketOfficialApi osTicketOfficialApi, int portNumber = 3306) { if (string.IsNullOrWhiteSpace(databaseServer)) { throw new ArgumentException("Database server cannot be null or empty", nameof(databaseServer)); } if (string.IsNullOrWhiteSpace(databaseUsername)) { throw new ArgumentException("Database username cannot be null or empty", nameof(databaseServer)); } if (string.IsNullOrWhiteSpace(databasePassword)) { throw new ArgumentException("Database password cannot be null or empty", nameof(databaseServer)); } if (string.IsNullOrWhiteSpace(databaseName)) { throw new ArgumentException("Database name cannot be null or empty", nameof(databaseServer)); } var osticketContext = BuildOSTicketContext( $"server={databaseServer};uid={databaseUsername};pwd={databasePassword};database={databaseName};port={portNumber};Convert Zero Datetime=True;"); OSTicketOfficialApi = osTicketOfficialApi; Tickets = new TicketRepository(osticketContext); Users = new UserRepository(osticketContext); HelpTopics = new HelpTopicsRepository(osticketContext); }
public OSTicketInstance(string connectionString, IOSTicketOfficalApi osTicketOfficalApi) { var optionsBuilder = new DbContextOptionsBuilder <OSTicketContext>(); optionsBuilder.UseMySQL(connectionString); var osticketContext = new OSTicketContext(optionsBuilder.Options); OSTicketOfficalApi = osTicketOfficalApi; Tickets = new TicketRepository(osticketContext); Users = new UserRepository(osticketContext); HelpTopics = new HelpTopicsRepository(osticketContext); }
public OSTicketInstance(string databaseServer, string databaseUsername, string databasePassword, string databaseName, IOSTicketOfficalApi osTicketOfficalApi, int portNumber = 3306) { var optionsBuilder = new DbContextOptionsBuilder <OSTicketContext>(); optionsBuilder.UseMySQL($"server={databaseServer};uid={databaseUsername};pwd={databasePassword};database={databaseName};port={portNumber};Convert Zero Datetime=True;"); var osticketContext = new OSTicketContext(new DbContextOptions <OSTicketContext>()); OSTicketOfficalApi = osTicketOfficalApi; Tickets = new TicketRepository(osticketContext); Users = new UserRepository(osticketContext); HelpTopics = new HelpTopicsRepository(osticketContext); }
public OSTicketService(string connectionString, IOSTicketOfficialApi osTicketOfficialApi) { if (string.IsNullOrWhiteSpace(connectionString)) { throw new ArgumentException("Connection string cannot be null or empty", nameof(connectionString)); } var osticketContext = BuildOSTicketContext(connectionString); OSTicketOfficialApi = osTicketOfficialApi; Tickets = new TicketRepository(osticketContext); Users = new UserRepository(osticketContext); HelpTopics = new HelpTopicsRepository(osticketContext); }