Skip to content

Instantly share code, notes, and snippets.

View ngohungphuc's full-sized avatar
🏡
Sài Gòn & Lelystad

Tony Ngo ngohungphuc

🏡
Sài Gòn & Lelystad
View GitHub Profile
internal class Clients
{
/// <summary>
/// App can access to IS
/// </summary>
/// <returns></returns>
public static IEnumerable<Client> Get()
{
return new List<Client> {
new Client {
public void ConfigureServices(IServiceCollection services)
{
const string connectionString = @"Data Source=IdentityServer.db;";
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddDbContext<ApplicationDbContext>(builder =>
builder.UseSqlite(connectionString, sqlOptions => sqlOptions.MigrationsAssembly(migrationsAssembly)));
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
InitializeDbTestData(app);
private static void InitializeDbTestData(IApplicationBuilder app)
{
using (var scope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
{
scope.ServiceProvider.GetRequiredService<PersistedGrantDbContext>().Database.Migrate();
scope.ServiceProvider.GetRequiredService<ConfigurationDbContext>().Database.Migrate();
scope.ServiceProvider.GetRequiredService<ApplicationDbContext>().Database.Migrate();
var context = scope.ServiceProvider.GetRequiredService<ConfigurationDbContext>();
dotnet ef migrations add ApplicationDb --context ApplicationDbContext
dotnet ef migrations add ConfigurationDb --context ConfigurationDbContext
dotnet ef migrations add PersistedGrantDb --context PersistedGrantDbContext
using System.Threading.Tasks;
namespace AwesomeCMSCore.Modules.Scheduled
{
public interface IScheduledEmailService
{
Task SendEmailBackground();
}
}
JobStorage.Current = new SqlServerStorage(configuration.GetConnectionString("DefaultConnection"));
var sp = services.BuildServiceProvider();
var scheduledEmailService = sp.GetService<IScheduledEmailService>();
RecurringJob.AddOrUpdate("SendSubscriptionEmail", () => scheduledEmailService.SendEmailBackground(), Cron.Minutely);
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<form [formGroup]="myForm">
<div>
<input type="text" class="form-input" [ngModel]="name" formControlName="name" />
</div>
<label class="form-group err-msg" *ngIf="myForm.get('name').hasError('required') && (name.get('name').dirty || myForm.get('name').touched)">Name is required</label>
<label class="form-group err-msg" *ngIf="myForm.get('name').hasError('whitespaces') && (name.get('name').dirty || myForm.get('name').touched)">Name is required</label>
<div>
<input type="text" class="form-input" [ngModel]="email" formControlName="email" />
public user$: IUser;
private userStoreSubscription: Subscription = new Subscription();
constructor(private store: Store<UserState>) {}
ngOnInit(): void {
this.userStoreSubscription = this.store.select(getUser).subscribe(res => {
this.user$ = res;
});
}