/// <summary> /// Creates new instance of <see cref="FooController"/>. /// </summary> /// <param name="connectionStrings"> /// Instance of <see cref="IOptionsSnapshot{ConnectionStrings}"/> object that contains connection string. /// More information: https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.options.ioptionssnapshot-1?view=aspnetcore-2.1 /// TODO: https://www.strathweb.com/2016/09/strongly-typed-configuration-in-asp-net-core-without-ioptionst/ /// </param> /// <param name="service">Instance of <see cref="IFooService"/></param> /// <param name="logger"></param> public FooController(IOptionsSnapshot <ConnectionStrings> connectionStrings, IFooService service, ILogger <FooController> logger, PlacesDBContext placesDBContext) { _connectionStrings = connectionStrings.Value ?? throw new ArgumentNullException(nameof(connectionStrings)); _service = service ?? throw new ArgumentNullException(nameof(service)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _placesDB = placesDBContext; }
public AccountController(PlacesDBContext placesDBContext) { try { this.placesDB = placesDBContext; } catch (Exception ex) { Console.Write(ex); } }