Loading src/web/Controllers/Api/AreasApiController.cs 0 → 100644 +42 −0 Original line number Diff line number Diff line using Cals.Visor.Infrastructure.Contexts; using Cals.Visor.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; namespace Cals.Visor.Web.Controllers.Api; [Route("api/areas")] [ApiController] public class AreasApiController : ControllerBase { private readonly ApplicationDbContext _context; public AreasApiController(ApplicationDbContext context) => _context = context; // GET: /api/areas [ProducesResponseType<Area>(StatusCodes.Status200OK)] [HttpGet(Name = "GetAllAreas")] public async Task<IActionResult> GetAllAsync() { List<Area> result = await _context.Areas .Where(e => e.IsActive == true) .ToListAsync(); return Ok(result); } // GET: /api/areas/1 [ProducesResponseType<Area>(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [HttpGet("{areaId:long}", Name = "GetAreaById")] public async Task<IActionResult> GetByIdAsync(long areaId) { Area? result = await _context.Areas .Where(e => e.AreaId == areaId) .FirstOrDefaultAsync(); if (result == null) return NotFound(); return Ok(result); } } Loading
src/web/Controllers/Api/AreasApiController.cs 0 → 100644 +42 −0 Original line number Diff line number Diff line using Cals.Visor.Infrastructure.Contexts; using Cals.Visor.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; namespace Cals.Visor.Web.Controllers.Api; [Route("api/areas")] [ApiController] public class AreasApiController : ControllerBase { private readonly ApplicationDbContext _context; public AreasApiController(ApplicationDbContext context) => _context = context; // GET: /api/areas [ProducesResponseType<Area>(StatusCodes.Status200OK)] [HttpGet(Name = "GetAllAreas")] public async Task<IActionResult> GetAllAsync() { List<Area> result = await _context.Areas .Where(e => e.IsActive == true) .ToListAsync(); return Ok(result); } // GET: /api/areas/1 [ProducesResponseType<Area>(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [HttpGet("{areaId:long}", Name = "GetAreaById")] public async Task<IActionResult> GetByIdAsync(long areaId) { Area? result = await _context.Areas .Where(e => e.AreaId == areaId) .FirstOrDefaultAsync(); if (result == null) return NotFound(); return Ok(result); } }