Ejemplo n.º 1
0
        private static async Task MainAsync()
        {
            // SETUP DI services
            var services = new ServiceCollection();

            services.AddTransient <IHelloWorldAPI, HelloWorldAPIv1>();

            // include these 2 lines if database support is needed
            //services.AddTransient<IHelloWorldDbApi, HelloWorldDbApiV1>();
            services.AddTransient <IHelloWorldRepository, HelloWorldRepositoryFakeDb>();
            var provider = services.BuildServiceProvider();

            // Resolve needed services
            IHelloWorldAPI api = provider.GetService <IHelloWorldAPI>();
            // Include these 2 lines if database support is needed
            //IHelloWorldDbApi dbapi = provider.GetService<IHelloWorldDbApi>();
            IHelloWorldRepository repository = provider.GetService <IHelloWorldRepository>();

            try
            {
                Console.WriteLine(await api.GetMessageAsync());

                // include this line if database write is needed.
                await api.SaveMessageAsync(await api.GetMessageAsync());

                Console.WriteLine("Data saved to repository");
            }
            catch (Exception ex)
            {
                throw new Exception("Error executing API methods.", ex);
            }
        }
        public HelloWorldController(IHelloWorldRepository repo)
        {
            _repo = repo;

            if (_repo.ListAll().Count() == 0)
            {
                _repo.Add();
            }
        }
Ejemplo n.º 3
0
 public HelloController(IHelloWorldRepository iHelloWorldRepository)
 {
     _helloWorldRepository = iHelloWorldRepository;
 }
Ejemplo n.º 4
0
 public HelloWorldService(IHelloWorldRepository helloWorldRepository)
 {
     _helloWorldRepository = helloWorldRepository;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor for the HelloWorldDbAPI
 /// </summary>
 /// <param name="helloWorldRepository">Injected IHelloWorldRepository object</param>
 public HelloWorldDbApiV1(IHelloWorldRepository helloWorldRepository)
 {
     repository = helloWorldRepository;
 }
Ejemplo n.º 6
0
 public HelloWorldService(IHelloWorldRepository repository)
 {
     this._repository = repository;
 }
 public HelloWorldController(IHelloWorldRepository _helloworldRepo)
 {
     this.helloworldRepository = _helloworldRepo;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Constructor with dependency injection
 /// </summary>
 /// <param name="repo"></param>
 public HelloWorldService(IHelloWorldRepository repo)
 {
     _repo = repo;
 }
Ejemplo n.º 9
0
 public HelloWorldAPIv1(IHelloWorldRepository helloWorldRepository)
 {
     repository = helloWorldRepository;
 }
Ejemplo n.º 10
0
 public HelloWorldController(IHelloWorldRepository repo)
 {
     HelloWorldRepo = repo;
 }
 public DefaultPresenter(IHelloWorldRepository repository)
 {
     _repository = repository;
 }
Ejemplo n.º 12
0
        // can break this out to a seperate project later so that it can be called from various applications
        // cmd prompt, web, android app, ect.

        public APIController(IHelloWorldRepository helloWorldRepository)
        {
            this.helloWorldRepository = helloWorldRepository;
        }
Ejemplo n.º 13
0
 public HelloWorldTest()
 {
     _repository = new SimpleHelloWorldRepository();
     _controller = new APIController(_repository);
 }
Ejemplo n.º 14
0
 public HelloWorldGetAllQueryHandler(IHelloWorldRepository helloWorldRepository)
 {
     this._helloWorldRepository = helloWorldRepository;
 }
 public HelloWorldController(IHelloWorldRepository helloWorldRepository)
 {
     _helloWorldRepository = helloWorldRepository;
 }