// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // 1. Add Authentication Services AuthenticationConfigurations.Configure(services, Configuration); services.AddAutoMapper(); services.AddDbContext <VideoServiceDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("Default"))); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddJsonOptions(options => { options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; }); services.AddOptions <AuthSettings>().Configure(o => { o.LifeTime = Convert.ToDouble(Configuration["AuthSettings:LifeTime"]); o.Secret = Configuration["AuthSettings:Secret"]; }); services.Configure <PhotoSettings>(Configuration.GetSection("PhotoSettings")); services.AddScoped <IMovieService, MovieService>(); services.AddScoped <IUserService, UserService>(); services.AddScoped <ICryptService, CryptService>(); // services.AddScoped<IUnitOfWorkService, UnitOfWorkService>(); services.AddScoped <IGenreService, GenreService>(); services.AddScoped <IRentalService, RentalService>(); services.AddScoped <ICoverService, CoverService>(); services.AddSingleton <IWriteToFileText, WriteToFileText>(); services.AddCors(); }
public bool Update(DeploymentManagerConfiguration candidate) { lock (this) { DateTime lastUpdateC = candidate.LastUpdate; DateTime lastUpdateT = this.LastUpdate; try { candidate.LastUpdate = DateTime.MinValue; this.LastUpdate = DateTime.MinValue; string orig = this.Serialize(); DeploymentManagerConfiguration test = DeploymentManagerConfiguration.Deserialize(orig) as DeploymentManagerConfiguration; test.SwitchboardConfigurationDescription = candidate.SwitchboardConfigurationDescription; test.AuthenticationConfigurations = candidate.AuthenticationConfigurations; test.DeploymentControllers = candidate.DeploymentControllers; test.InstructionSetTemplates = candidate.InstructionSetTemplates; test.AdHocInstructionSets = candidate.AdHocInstructionSets; test.InstructionSetStatics = candidate.InstructionSetStatics; foreach (SwitchboardConfig.FileSourcesRow r in candidate.SwitchboardConfiguration.FileSources) { if (r.IsAuthenticationFilenameNull()) { return(false); } else if (String.IsNullOrEmpty(r.AuthenticationFilename)) { return(false); } } if (orig == test.Serialize()) { return(false); } STEM.Sys.EventLog.WriteEntry("DeploymentManagerConfiguration.Update", "Update applied.", STEM.Sys.EventLog.EventLogEntryType.Information); SwitchboardConfigurationDescription = candidate.SwitchboardConfigurationDescription; AuthenticationConfigurations.Clear(); AuthenticationConfigurations.AddRange(candidate.AuthenticationConfigurations); DeploymentControllers.Clear(); DeploymentControllers.AddRange(candidate.DeploymentControllers); InstructionSetTemplates.Clear(); InstructionSetTemplates.AddRange(candidate.InstructionSetTemplates); AdHocInstructionSets.Clear(); AdHocInstructionSets.AddRange(candidate.AdHocInstructionSets); foreach (string sub in candidate.InstructionSetStatics.Keys) { InstructionSetStatics[sub].Clear(); InstructionSetStatics[sub].AddRange(candidate.InstructionSetStatics[sub]); } if (orig != this.Serialize()) { if (lastUpdateC > DateTime.MinValue) { LastUpdate = lastUpdateC; } else { LastUpdate = DateTime.UtcNow; } return(true); } else { LastUpdate = lastUpdateT; if (LastUpdate < lastUpdateC) { LastUpdate = lastUpdateC; } return(false); } } finally { if (LastUpdate == DateTime.MinValue) { LastUpdate = lastUpdateT; } if (LastUpdate == DateTime.MinValue) { LastUpdate = DateTime.UtcNow; } } } }