I have created a new project in ASP.Net Web API but having trouble pulling through the data from the Model to the Controller. I have tried a few approaches so far and read the tutorials from http://www.asp.net/web-api, but the table data, which is pulled through fine to the model does not make it to the controller for endpoint access. Is there a specific approach needed for these operations as the mock data used in the tutorials worked fine with the same structure?
Interface:
public interface ISkillRepository
{
IEnumerable<Skill> GetAll();
Skill Get(int id);
Skill Add(Skill item);
void Remove(int id);
bool Update(Skill item);
}
Model:
public IEnumerable<Skill> GetAll()
{
using (var db = new XXXEntities())
{
var skills = db.Skill.ToList();
return skills;
}
}
Controller:
static readonly ISkillRepository repository = new SkillsRepository();
public IEnumerable<Skill> GetAllSkill()
{
return repository.GetAll();
}
The model makes a successful call to the database and retrieves the information, however it does not pass successfully to the controller, which is being accessed as an endpoint. Pulling the model code into the controller also executes successfully but still throws a 500 when requested. There are no errors about incorrect return type etc. Any help would be much appreciated.