// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TurnipContext context) { app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); context.Database.Migrate(); TurnipInitializer.Initialize(context, env); app.UseCors(policy => policy.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //app.UseHttpsRedirection(); app.UseSerilogRequestLogging(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapHealthChecks("/health"); }); }
public UsersController(TurnipContext context, IMapper mapper, IUserService userService, IOptions <ApplicationSettings> settings) { _mapper = mapper; _userService = userService; _settings = settings.Value; _context = context; }
public static void Initialize(TurnipContext context, IWebHostEnvironment env) { context.Database.EnsureCreated(); if (!context.Timezones.Any()) { var tzs = JsonConvert.DeserializeObject <IEnumerable <Timezone> >(File.ReadAllText(Path.Combine(env.ContentRootPath, "database", "data", "timezones.json"))); context.Timezones.AddRange(tzs); context.SaveChanges(); } }
public async Task VerifyWeeks(TurnipContext context, Board board, string timezoneId) { var currentWeek = DateTimeExtensions.NowInLocale(timezoneId).ToStartOfWeek(); var userIds = board.Users.Select(bu => bu.RegisteredUserId); foreach (var userId in userIds) { var user = await context.RegisteredUsers.Include(u => u.Weeks).SingleOrDefaultAsync(u => u.Id.Equals(userId)); if (!user.Weeks.Any(w => w.WeekDate.Equals(currentWeek))) { user.Weeks.Add(new Week { WeekDate = currentWeek }); } } await context.SaveChangesAsync(); }
public UserService(TurnipContext context, ILogger <UserService> logger, IEmailService email) { _context = context; _logger = logger; _email = email; }
public BoardsController(IMapper mapper, TurnipContext context, IBoardService boardService) { _mapper = mapper; _context = context; _boardService = boardService; }
public PricesController(TurnipContext context, IMapper mapper) { _context = context; _mapper = mapper; }