static int Main(string[] args) { RootCommand root = new RootCommand(); Command addUser = new Command("adduser") { new Option <string>(new string[] { "--username", "-u" }, description: "The name of the user/account"), new Option <string>(new string[] { "--password", "-p" }, description: "The password for the new user/account"), }; addUser.Handler = CommandHandler.Create <string, string>(async(username, password) => { IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .AddJsonFile("secrets.json", true, true) .Build(); CalorieContext db = new CalorieContext(config); AuthService auth = new AuthService(db); await auth.CreateUserAsync(username, password); Console.WriteLine("User {0} created", username); }); root.Add(addUser); return(root.InvokeAsync(args).Result); }
public static void Main(string[] args) { IHost host = CreateHostBuilder(args).Build(); using (IServiceScope serviceScope = host.Services.CreateScope()) { CalorieContext context = serviceScope.ServiceProvider.GetRequiredService <CalorieContext>(); context.Database.EnsureCreated(); } host.Run(); }
public CalorieService(CalorieContext DB) { _db = DB; }
public CalorieRepository(CalorieContext calorieContext) { CalorieContext = calorieContext; }
public AuthService(CalorieContext DB) { _db = DB; }