Ejemplo n.º 1
0
 public MessageBuilder(IEmailBodyGenerator generator, EmailConfigurationModel emailConfiguration, IConfigRepository сonfigRepository, IMapper mapper)
 {
     _emailBodyGenerator = generator;
     _emailConfiguration = emailConfiguration;
     _сonfigRepository   = сonfigRepository;
     _mapper             = mapper;
 }
Ejemplo n.º 2
0
        public async Task <AppDomainResult> UpdateEmailConfiguration([FromBody] EmailConfigurationModel emailConfigurationModel)
        {
            AppDomainResult appDomainResult = new AppDomainResult();

            if (ModelState.IsValid)
            {
                emailConfigurationModel.EncryptPassword();
                var  emailConfiguration = mapper.Map <EmailConfiguration>(emailConfigurationModel);
                bool success            = await this.emailConfigurationService.UpdateAsync(emailConfiguration);

                if (success)
                {
                    appDomainResult = new AppDomainResult()
                    {
                        Success    = true,
                        ResultCode = (int)HttpStatusCode.OK,
                    };
                }
                else
                {
                    throw new Exception("Lỗi trong quá trình xử lý!");
                }
            }
            else
            {
                throw new AppException(ModelState.GetErrorMessage());
            }
            return(appDomainResult);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// SaveEmailConfiguration
        /// </summary>
        /// <param name="emailConfigurationModel"></param>
        public void SaveEmailConfiguration(EmailConfigurationModel emailConfigurationModel)
        {
            EmailConfigurationDC emailConfigurationDC       = Mapper.Map <EmailConfigurationModel, EmailConfigurationDC>(emailConfigurationModel);
            ServiceResponse      emailConfigurationResponse = _setupProxy.Execute(opt => opt.SaveEmailConfiguration(emailConfigurationDC));

            if (emailConfigurationResponse.Status != ResponseStatus.Success)
            {
                HandleError(emailConfigurationResponse.Status, emailConfigurationResponse.ResponseMessage);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// GetEmailConfiguration
        /// </summary>
        /// <returns></returns>
        public EmailConfigurationModel GetEmailConfiguration()
        {
            EmailConfigurationModel emailConfiguration = null;
            ServiceResponse <EmailConfigurationDC> emailConfigurationResponse = _setupProxy.Execute(opt => opt.GetEmailConfiguration());

            if (emailConfigurationResponse.Status != ResponseStatus.Success)
            {
                HandleError(emailConfigurationResponse.Status, emailConfigurationResponse.ResponseMessage);
            }
            else
            {
                emailConfiguration = Mapper.Map <EmailConfigurationDC, EmailConfigurationModel>(emailConfigurationResponse.Result);
            }
            return(emailConfiguration);
        }
Ejemplo n.º 5
0
 public HttpResponseMessage SaveEmailConfiguration(EmailConfigurationModel emailConfiguration)
 {
     SetupClientProcessor.SaveEmailConfiguration(emailConfiguration);
     return(Request.CreateResponse(HttpStatusCode.OK, CoreMessages.SavedSuccessfully));
 }
Ejemplo n.º 6
0
        public HttpResponseMessage GetEmailConfiguration()
        {
            EmailConfigurationModel emailConfigurationModel = SetupClientProcessor.GetEmailConfiguration();

            return(Request.CreateResponse(HttpStatusCode.OK, emailConfigurationModel));
        }
Ejemplo n.º 7
0
 public HttpResponseMessage SaveEmailConfiguration(EmailConfigurationModel emailConfiguration)
 {
     SetupClientProcessor.SaveEmailConfiguration(emailConfiguration);
     return Request.CreateResponse(HttpStatusCode.OK, CoreMessages.SavedSuccessfully);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// SaveEmailConfiguration
 /// </summary>
 /// <param name="emailConfigurationModel"></param>
 public void SaveEmailConfiguration(EmailConfigurationModel emailConfigurationModel)
 {
     EmailConfigurationDC emailConfigurationDC = Mapper.Map<EmailConfigurationModel, EmailConfigurationDC>(emailConfigurationModel);
     ServiceResponse emailConfigurationResponse = _setupProxy.Execute(opt => opt.SaveEmailConfiguration(emailConfigurationDC));
     if (emailConfigurationResponse.Status != ResponseStatus.Success)
     {
         HandleError(emailConfigurationResponse.Status, emailConfigurationResponse.ResponseMessage);
     }
 }
Ejemplo n.º 9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = "JwtBearer";
                options.DefaultChallengeScheme    = "JwtBearer";
            }).
            AddJwtBearer("JwtBearer", jwtOptions =>
            {
                jwtOptions.TokenValidationParameters = new TokenValidationParameters()
                {
                    IssuerSigningKey         = UserRepository.SIGN_IN_KEY,
                    ValidateIssuer           = false,
                    ValidateAudience         = false,
                    ValidateIssuerSigningKey = true,
                    ValidateLifetime         = true,
                    ClockSkew = TimeSpan.FromMinutes(5)
                };
            });

            services.AddCors(options =>
            {
                options.AddPolicy(MyAllowSpecificOrigins,
                                  builder =>
                {
                    builder.WithOrigins("https://bdmi.netlify.app", "http://localhost:3000").AllowAnyHeader().AllowAnyMethod().AllowCredentials();
                });
            });

            EmailConfigurationModel emailConfig = Configuration
                                                  .GetSection("EmailConfiguration")
                                                  .Get <EmailConfigurationModel>();

            emailConfig.Password = Environment.GetEnvironmentVariable("EMAIL_PASSWORD");
            services.AddSingleton(emailConfig);
            services.AddHostedService <UpdateDatabase>();
            services.AddDbContextPool <MovieContext>(option => { option.UseNpgsql(Environment.GetEnvironmentVariable("CONNECTION_STRING")); });
            services.AddIdentity <User, IdentityRole>(opt =>
            {
                opt.User.RequireUniqueEmail      = true;
                opt.SignIn.RequireConfirmedEmail = true;
            })
            .AddEntityFrameworkStores <MovieContext>()
            .AddDefaultTokenProviders();

            services.Configure <IdentityOptions>(config =>
            {
                config.Password.RequiredLength         = 6;
                config.Password.RequireDigit           = true;
                config.Password.RequireNonAlphanumeric = true;
                config.Password.RequireLowercase       = true;
                config.Password.RequireUppercase       = true;
            });
            services.AddControllers();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "bdmI API", Version = "v1"
                });
                //string xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                //string xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                //c.IncludeXmlComments(xmlPath);
            });
        }
Ejemplo n.º 10
0
 public EmailSender(EmailConfigurationModel emailConfiguration)
 {
     _emailConfiguration = emailConfiguration;
 }