public CommandsDispatcher( IMediator mediator, TreesContext treesContext) { this._mediator = mediator; this._treesContext = treesContext; }
public UnitOfWork( TreesContext treesContext, IDomainEventsDispatcher domainEventsDispatcher) { this._treesContext = treesContext; this._domainEventsDispatcher = domainEventsDispatcher; }
private async Task GenerateOrUpdateDomainUserProfile(HttpContext context, TreesContext treesContext) { var mail = context.GetUserEmail(); var userAuthId = context.GetFirebaseUserAuthId(); if (!string.IsNullOrEmpty(userAuthId)) { var user = await treesContext.Users.FirstOrDefaultAsync(u => u.UserAuthId == userAuthId); if (user is null) { user = UserProfile.CreateUserProfile(userAuthId, new MailAddress(mail), null, null, null, _userAuthIdUniquenessChecker); await treesContext.Users.AddAsync(user); } else if (!Equals(user.ContactEmailAddress?.Address, mail)) { user.UpdateContactEmailAddress(new MailAddress(mail)); } await treesContext.SaveChangesAsync(); } }
public UnitOfWorkCommandHandlerWithResultDecorator( ICommandHandler <T, TResult> decorated, IUnitOfWork unitOfWork, TreesContext treesContext) { _decorated = decorated; _unitOfWork = unitOfWork; _treesContext = treesContext; }
private void SaveChanges(object obj) { using (TreesContext context = new TreesContext()) { foreach (var item in (ObservableCollection <Tree>)obj) { context.Trees.Add(item); } context.SaveChanges(); } }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TreesContext context) { app.UseCors(cfg => { (env.IsProduction() ? cfg.WithOrigins(_configuration["AllowedOrigins"].Split(";")) .AllowCredentials() : cfg.AllowAnyOrigin()) .AllowAnyMethod() .AllowAnyHeader() .SetPreflightMaxAge(TimeSpan.FromMinutes(60)); }); app.UseAuthentication(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseProblemDetails(); } app.UseRouting(); app.UseAuthorization(); app.UseMiddleware <CorrelationMiddleware>(); app.UseMiddleware <LoggingMiddleware>(); app.UseMiddleware <UserProfileMiddleware>(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseSwaggerDocumentation(); context.Database.Migrate(); }
public TreeRepository(TreesContext treesContext) { _treesContext = treesContext; }
public async Task Invoke(HttpContext context, TreesContext treesContext) { await GenerateOrUpdateDomainUserProfile(context, treesContext); await _next.Invoke(context); }
public DomainEventsDispatcher(IMediator mediator, ILifetimeScope scope, TreesContext treesContext) { this._mediator = mediator; this._scope = scope; this._treesContext = treesContext; }
public UserProfileRepository(TreesContext dbContext) { _dbContext = dbContext; }
public TreeQueryRepository(TreesContext treesContext, IUserProfileRepository userProfileRepository) { _treesContext = treesContext; _userProfileRepository = userProfileRepository; }