Posts

Showing posts from December, 2014

Injecting a service into a view in MVC 6

Image
  Asp.net MVC 6 supports injecting service to view using a class. Example :- When country combo box value get changed , region com Only restriction is that class should be Public Non-nested Non-Abstract 1. Create a Asp.Net Project in Visual Studio 2015     2. Create a folder name services and add a service class. using System; using System.Threading.Tasks;   namespace ViewInjection.Services {      public class EmployeeService      {          public async Task < int > GetEmployeesOnLeaveCount()          {              return await Task .FromResult(5);          }            public async Task < int > GetEmployeesOnSiteCount()          {              return await Task .FromResult(                  10);          }            public async Task < int > GetEmployeesOnWorkCount()          {              return await Task .FromResult(97);          }      } }   2. Create a View to ...