using Casestudy.DAL; using Casestudy.DAL.DAO; using Casestudy.DAL.DomainClasses; using Casestudy.Migrations; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Text.Json; namespace Casestudy.Controllers { [Route("api/[controller]")] [ApiController] [Authorize] public class BranchController : ControllerBase { readonly AppDbContext? _ctx; public BranchController(AppDbContext context) // injected here { _ctx = context; } [HttpGet("{lat}/{lon}")] public async Task<ActionResult<List<Branch>?>> Index(float lat, float lon) { BranchDAO dao = new(_ctx!); return await dao.GetThreeClosestStores(lat, lon); } } }