using System;
using Microsoft.AspNetCore.Mvc;
using ITVisions;

namespace ASPNET.Controllers
{
 public class POCODIController
 {
  private FlugService flugservice1;
  private IFlugService flugservice2;

  public POCODIController
(FlugService flugservice1, IFlugService flugservice2)
  {
   this.flugservice1 = flugservice1;
   this.flugservice2 = flugservice2;
  }

  [ActionContext]
  public ActionContext actionContext { get; set; }
  [ControllerContext]
  public ControllerContext controllerContext { get; set; }

  // Aufruf = Standardroute: http://localhost:12345/pocodi/index
  public IActionResult Index()
  {
   var s = "Injizierte Dienste<hr>" + this.flugservice1.GetType().FullName + ": " + this.flugservice1.ToString() + "<br>" + this.flugservice2.GetType().FullName + ": " + this.flugservice2.ToString() + "<br>";

   var flugservice3 = actionContext.HttpContext.RequestServices.GetService(typeof(FlugService));
   var flugservice4 = actionContext.HttpContext.RequestServices.GetService(typeof(IFlugService));
   s += flugservice3.GetType().FullName + ": " + flugservice3.ToString() + "<br>"; ;

   s += flugservice4.GetType().FullName + ": " + flugservice4.ToString() + "<br>"; ;

   return new ContentResult()
   {
    ContentType = "text/html",
    Content = "<html><body><h2>DI-Demo</h2><p>" + s
      + "</p></body></html>"
   };
  }


 }
}
