Please help me with this Route
using Northwind.Models;
using Northwind.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Northwind.Dto;
using AutoMapper;
using Northwind.Repository;
using Microsoft.EntityFrameworkCore;
namespace Northwind.Controllers
{
public class EmployeeController
{
[ApiController] [Route("api/[controller]")]
public class EmployeeControllers : ControllerBase { NorthwindContext db = new NorthwindContext(); private readonly IEmployeeRepository _employeeRepository; // Use interface for dependency injection private readonly NorthwindContext context; public EmployeeControllers(IEmployeeRepository employeeRepository, NorthwindContext context) // Inject repository in constructor { _employeeRepository = employeeRepository; this.context = context; } [HttpGet] [ProducesResponseType(200)] public IActionResult GetEmployees() { var employees = _employeeRepository.GetEmployees(); if (!ModelState.IsValid) return BadRequest(ModelState); return Ok(employees);
} } } } I dont know how to solve it, if you have any idea, i'm really apriciate
[ApiController] [Route("api/[controller]")]
public class EmployeeControllers : ControllerBase { NorthwindContext db = new NorthwindContext(); private readonly IEmployeeRepository _employeeRepository; // Use interface for dependency injection private readonly NorthwindContext context; public EmployeeControllers(IEmployeeRepository employeeRepository, NorthwindContext context) // Inject repository in constructor { _employeeRepository = employeeRepository; this.context = context; } [HttpGet] [ProducesResponseType(200)] public IActionResult GetEmployees() { var employees = _employeeRepository.GetEmployees(); if (!ModelState.IsValid) return BadRequest(ModelState); return Ok(employees);
} } } } I dont know how to solve it, if you have any idea, i'm really apriciate
6 Replies
How to solve... what?
Show program.cs
I'm sorry for missing this
Try adding
app.UseSwagger();
app.UseSwaggerUI();
I have added it but it cant changed anything:<<