public static void CreateProjectStatus(TeamTasksDbContext db) { ProjectStatusManager <ProjectStatus> PM = new ProjectStatusManager <ProjectStatus>(new ProjectStatusStore(db)); var res = PM.CreateAsync(new ProjectStatus { Name = "Unknown" }).Result; var dummy = 3; }
public static void UpdateProjectStatus(TeamTasksDbContext db) { ProjectStatusManager <ProjectStatus> PM = new ProjectStatusManager <ProjectStatus>(new ProjectStatusStore(db)); ProjectStatus projectStatus = PM.FindByIdAsync(8).Result; projectStatus.Name = "dropped"; var res = PM.UpdateAsync(projectStatus).Result; var dummy = 3; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, TeamTasksDbContext db, UserManager <TeamTasksUser> userManager, RoleManager <TeamTasksRole> roleManager) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } Seeder seeder = new Seeder(db, userManager, roleManager); await seeder.InitializeDataAsync(); app.Run(async(context) => { await context.Response.WriteAsync("Hello World!"); }); }
static void Main(string[] args) { var builder = new ConfigurationBuilder(); builder.SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); Configuration = builder.Build(); var services = new ServiceCollection(); string connectionString = Configuration["TeamTasksConnectionString"]; services.AddDbContext <TeamTasksDbContext>(options => { options.UseSqlServer(connectionString, opts => { opts.UseRowNumberForPaging(); }); }); services.AddIdentity <TeamTasksUser, TeamTasksRole>() .AddEntityFrameworkStores <TeamTasksDbContext, int>() .AddDefaultTokenProviders(); var provider = services.BuildServiceProvider(); TeamTasksDbContext db = provider.GetRequiredService <TeamTasksDbContext>(); //ProjectStatusTests.CreateProjectStatus(db); //ProjectStatusTests.UpdateProjectStatus(db); //CryptopgraphyTests.TestCryptography(); CryptopgraphyTests.TestWebTokens(); var dummy = 3; Console.WriteLine("Hello World!"); Console.ReadLine(); }
public ProjectsController(TeamTasksDbContext context, UserManager <TeamTasksUser> userManager) { db = context; projectManager = new ProjectManager <Project>(new ProjectStore(db)); this.userManager = userManager; }
public TeamTasksController(TeamTasksDbContext context, UserManager <TeamTasksUser> userManager) { db = context; teamTaskManager = new TeamTaskManager <TeamTask>(new TeamTaskStore(db)); this.userManager = userManager; }
public static async Task <AuthenticatedInfo> ResolveAuthenticatedEntitiesAsync(this Controller controller, TeamTasksDbContext context, UserManager <TeamTasksUser> userManager) { string username = controller.Request.HttpContext.User?.Identity?.Name ?? ""; TeamTasksUser user = await userManager.FindByNameAsync(username); int userId = user?.Id ?? 0; return(new AuthenticatedInfo { UserId = userId }); }