// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(); services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddJsonOptions(options => { options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; }); //services.AddDbContext<TPCOHDBContext>(optionsAction: x => x.UseSqlServer(Configuration["ConnectionStrings:DefaultConnection"], // sqlServer => sqlServer.MigrationsHistoryTable(DataBaseConstantDBL.MigrationTable, DataBaseConstantDBL.MigrationSchema))); Dependencies.ConfigureDI(services); //DependenciesBAL.ConfigureDI(services); //DependenciesDAL.ConfigureDI(services); services.Configure <ApiBehaviorOptions>(options => options.InvalidModelStateResponseFactory = (context) => { var errors = context.ModelState.Values.SelectMany(x => x.Errors.Select(p => p.ErrorMessage)).ToList(); var result = new { Code = "001", Message = "Validation errors", Errors = errors }; return(new BadRequestObjectResult(result)); }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Version = "v1", Title = "TPCOHAdmin", Description = "Part of TPCOH" }); var filePath = Path.Combine(AppContext.BaseDirectory, "TPCOHAdmin.xml"); c.IncludeXmlComments(filePath); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddCors(); services.AddDbContext <MTSDBContext>(); Dependencies.ConfigureDI(services); DependenciesBAL.ConfigureDI(services); DependenciesUtilities.ConfigureDI(services); services.Configure <ApiBehaviorOptions>(options => options.InvalidModelStateResponseFactory = (context) => { var errors = context.ModelState.Values.SelectMany(x => x.Errors.Select(p => p.ErrorMessage)).ToList(); var result = new { Code = "001", Message = "Validation errors", Errors = errors }; return(new BadRequestObjectResult(result)); }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Version = "v1", Title = "MTS", Description = "Medical Tracking system" }); var filePath = Path.Combine(AppContext.BaseDirectory, "MTS.API.xml"); c.IncludeXmlComments(filePath); }); }