Пример #1
0
 public CommandsDispatcher(
     IMediator mediator,
     TreesContext treesContext)
 {
     this._mediator     = mediator;
     this._treesContext = treesContext;
 }
Пример #2
0
 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();
            }
        }
Пример #4
0
 public UnitOfWorkCommandHandlerWithResultDecorator(
     ICommandHandler <T, TResult> decorated,
     IUnitOfWork unitOfWork,
     TreesContext treesContext)
 {
     _decorated    = decorated;
     _unitOfWork   = unitOfWork;
     _treesContext = treesContext;
 }
Пример #5
0
        private void SaveChanges(object obj)
        {
            using (TreesContext context = new TreesContext())
            {
                foreach (var item in (ObservableCollection <Tree>)obj)
                {
                    context.Trees.Add(item);
                }

                context.SaveChanges();
            }
        }
Пример #6
0
        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();
        }
Пример #7
0
 public TreeRepository(TreesContext treesContext)
 {
     _treesContext = treesContext;
 }
        public async Task Invoke(HttpContext context, TreesContext treesContext)
        {
            await GenerateOrUpdateDomainUserProfile(context, treesContext);

            await _next.Invoke(context);
        }
Пример #9
0
 public DomainEventsDispatcher(IMediator mediator, ILifetimeScope scope, TreesContext treesContext)
 {
     this._mediator     = mediator;
     this._scope        = scope;
     this._treesContext = treesContext;
 }
 public UserProfileRepository(TreesContext dbContext)
 {
     _dbContext = dbContext;
 }
Пример #11
0
 public TreeQueryRepository(TreesContext treesContext, IUserProfileRepository userProfileRepository)
 {
     _treesContext          = treesContext;
     _userProfileRepository = userProfileRepository;
 }