using Microsoft.AspNetCore.Mvc;
using MeteoWebApp.Data;
using System.Linq;
using System.Threading.Tasks;

namespace MeteoWebApp.ViewComponents
{
    [ViewComponent(Name = "StationsDropDown")]
    public class StationsDropDownViewComponent : ViewComponent
    {
        private readonly MeteoDbContext _db;
        public StationsDropDownViewComponent(MeteoDbContext db)
        {
            _db = db;
        }

        public async Task<IViewComponentResult> InvokeAsync()
        {
            return View("StationsDropDown", _db.Stations.ToList());
        }
    }
}
