Exemplo n.º 1
0
 public BusinessDateController(IMapper mapper,
                               IBusinessDateRepository businessDateRepository,
                               IDateService dateService,
                               IUnitOfWork unitOfWork)
 {
     this.unitOfWork             = unitOfWork;
     this.businessDateRepository = businessDateRepository;
     this.DateService            = dateService;
     this.mapper = mapper;
 }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              RoleManager <IdentityRole> roleManager,
                              IBusinessDateRepository businessDateRepository,
                              IDateService dateService,
                              IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                Console.WriteLine("In Development mode");
                Console.WriteLine("Database Connection String: " + Configuration.GetConnectionString("Default"));
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseExceptionHandler(
                builder =>
            {
                builder.Run(
                    async context =>
                {
                    context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                    context.Response.Headers.Add("Access-Control-Allow-Origin", "*");

                    var error = context.Features.Get <IExceptionHandlerFeature>();
                    if (error != null)
                    {
                        //context.Response.AddApplicationError(error.Error.Message);
                        await context.Response.WriteAsync(error.Error.Message).ConfigureAwait(false);
                    }
                });
            });

            app.UseAuthentication();
            app.UseDefaultFiles();
            app.UseCors("AllowAll");
            app.UseStaticFiles();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                routes.MapSpaFallbackRoute(
                    name: "spa-fallback",
                    defaults: new { controller = "Home", action = "Index" });
            });
            app.UseAuthentication();

            //Create Roles if not exist
            //CORE DUMP ONCE SET!!!!!!!! TODO!!!!!!
            CreateUserRoles(serviceProvider).Wait();

            //Create Admin User if not exist
            CreateAdminUser(serviceProvider).Wait();

            //Create List Of Status if not already set
            CreatePlanningAppStatuses(serviceProvider).Wait();

            //Set global date, ovverride if set
            var options = new DateSettings();

            Configuration.GetSection("DateSettings").Bind(options);
            setApplicationDate(options.CurrentDateOverride, dateService, businessDateRepository);
        }
Exemplo n.º 3
0
        public void setApplicationDate(string currentDateOverride, IDateService dateService, IBusinessDateRepository businessDateRepository)
        {
            var businessDate = !string.IsNullOrEmpty(currentDateOverride) ? currentDateOverride.ParseInputDate() : DateTime.Now.Date;

            dateService.SetCurrentDate(businessDate);
        }
Exemplo n.º 4
0
 public DateService(IBusinessDateRepository IBusinessDateRepository)
 {
     this.IBusinessDateRepository = IBusinessDateRepository;
 }