Hello Nishant,
you need to add the interface reference to the controller. I hope you are aware of dependency Injection and used a tool out of Unity, Ninject, StructureMap3 to resolve the injection.
For adding the reference you need to add a parameterized constructor to the controller like below:-
public class HomeController : Controller
{
private readonly IProductService _productService;
public HomeController(IProductService productService)
{
_productService = productService;
}
}
NOTE:- This will only work out, if you have used Dependency Resolver as mentioned above the Nuget Package tools. Else you will get error saying,
No parameterless constructor defined
In the Interface:-
namespace YOUR NAMESPACE GOES HERE
{
public interface IProductService
{
void CreateProduct(MODEL/CLASS);
}
}
=================================================
public class ProductService : IProductService
{
}
Hope this helps
Post back your queries if any.
Thanks
:)