public LogService(
     SMDBContext context,
     IOptions <AppSettings> app)
 {
     _context     = context;
     _appSettings = app;
 }
        private void DeleteOlderLogs(SMDBContext context)
        {
            var logs = context.Logs.ToList();

            foreach (var log in logs)
            {
                if (LogLifeChecker(log))
                {
                    context.Logs.Remove(log);
                }
            }
            context.SaveChangesAsync();
        }
Пример #3
0
 public LikeService(SMDBContext context)
 {
     _context = context;
 }
 public PostService(SMDBContext context)
 {
     _context = context;
 }
Пример #5
0
 public LicenseSystemService(SMDBContext dbContext)
 {
     this.dbContext = dbContext;
 }
Пример #6
0
 public UserService(SMDBContext context)
 {
     _context = context;
 }
Пример #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, SMDBContext sMDBContext)
        {
            #region Localization
            app.UseRequestLocalization(app.ApplicationServices.GetRequiredService <IOptions <RequestLocalizationOptions> >().Value);
            var cultures = new List <CultureInfo> {
                new CultureInfo("en"),
                new CultureInfo("ar")
            };
            app.UseRequestLocalization(options =>
            {
                options.DefaultRequestCulture = new Microsoft.AspNetCore.Localization.RequestCulture("en");
                options.SupportedCultures     = cultures;
                options.SupportedUICultures   = cultures;
            });
            #endregion

            // migrate any database changes on startup (includes initial db creation)
            sMDBContext.Database.Migrate();


            app.UseRouting();

            // global cors policy
            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints => endpoints.MapControllers());

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            if (!env.IsDevelopment())
            {
                app.UseSpaStaticFiles();
            }

            app.UseRouting();

            app.UseSpa(spa =>
            {
                // To learn more about options for serving an Angular SPA from ASP.NET Core,
                // see https://go.microsoft.com/fwlink/?linkid=864501

                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            });

            // Swagger Configuration in API
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API v1");
            });
        }
 public FriendshipService(SMDBContext context)
 {
     _context = context;
 }