Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Response data as XML or JSON based on request url.
            services.AddControllers().AddXmlDataContractSerializerFormatters();


            services.AddControllers().SetCompatibilityVersion(CompatibilityVersion.Version_3_0).AddNewtonsoftJson(options =>
            {
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });
            //sqlserver database register
            services.AddDbContext <HRMDbContext>(a => a.UseSqlServer(Configuration.GetConnectionString("HRMDbConnection_2")));

            //registering all repositories
            RepositoryInjections.InjectRepositories(services);

            //registering all Services
            ServicesInjections.InjectServices(services);

            //registering Mapper
            services.AddAutoMapper(Assembly.GetAssembly(typeof(MappingProfiles)));

            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "HRM API", Version = "v1"
                });
            });

            services.AddOData();
        }
Example #2
0
        //string conn = "Server=tcp:hsportsdaniel.database.windows.net,1433;Initial Catalog=DotNetChat;Persist Security Info=False;User ID=daniel;Password=Certified.101;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContextPool <ChatDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DotNetChatAppDBConnection")));
            services.AddControllers();
            RepositoryInjections.InjectedRepositories(services);
        }