hello ,
I was tring to create web api controller and return object for that ive written code but it only gives me error message because i have noticed that it is not calling webapiconfig. ive called it from application_start() in Global.aspx but it is not calling that too . can anyone tell me what is missing and how the flow of it going and how can i call my controller . my web api code and weapiconfig code is written bellow
namespace SmartStore.Web
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "index", id = RouteParameter.Optional }
);
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
}
}
}
namespace SmartStore.Web.WebApiController
{
[WebApiAuthenticate]
public class VINController : ApiController
{
private readonly IManufacturerInfoService _manufacturerInfoService;
private readonly IModelInfoService _modelInfoService;
private readonly IWMIInfoService _wmiInfoService;
public VINController(IManufacturerInfoService manufacturerInfoService, IModelInfoService modelInfoService, IWMIInfoService wmiInfoService)
{
this._manufacturerInfoService = manufacturerInfoService;
this._modelInfoService = modelInfoService;
this._wmiInfoService = wmiInfoService;
}
public dynamic Get()
{
dynamic ManufacturesInfo = null;
dynamic ModelInfos = null;
dynamic WMIInfos = null;
var ManufacturersInfo = _manufacturerInfoService.GetAllManufacturerInfo();
var ModelInfo = _modelInfoService.getAllModelInfo();
var WMIInfo = _wmiInfoService.getAllWMIInfo();
foreach (var i in ManufacturersInfo)
{
ManufacturesInfo = from item in ManufacturersInfo
select new
{
Id = item.Manufacture_code,
Manufacturer = item.Manufacturer_Name
};
}
foreach (var a in ModelInfo)
{
ModelInfos = from item in ModelInfo
select new
{
Manu_Id = item.Manu_Id,
Code = item.Model_Code,
Model = item.Model_Name
};
}
WMIInfos = from item in WMIInfo
select new
{
initchar = item.Init_char,
id = item.Code,
Region = item.Region,
name = item.Name
};
return new { ManufacturesInfo = ManufacturesInfo, ModelInfos = ModelInfos, WMIInfos = WMIInfos };
}
}
}