// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); var tenantStorage = new TenantStorageList(); var rentalStorage = new RentalStorageList(); var assignmentStorage = new AssignStorageList(); var rentManagement = new RentManagementSystem(rentalStorage, tenantStorage, assignmentStorage); services.AddSingleton <RentManagementSystem>(rentManagement); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); //build a singleton RentManagementSytem instance and inject it into any controller that needs it. //to override deserialization services.AddControllers().AddNewtonsoftJson(); //Initilaize the list implementation for the storage systems var tenantStorageSystem = new TenantStorageList(); var rentalStorageSystem = new RentalStorageList(); var assignmentStorageSystem = new AssignStorageList(); //Inject the storage system into the rentmanagment system var _rentManagementSystem = new RentManagementSystem(rentalStorageSystem, tenantStorageSystem, assignmentStorageSystem); //And then inject that rentmanagement system as a service into the web appilcation services.AddSingleton <RentManagementSystem>(_rentManagementSystem); }