using IBCPackTrack.Data; >>>>using IBCPackTrack.Models; >>>>using IBCPackTrack.Web.Filters; >>>>using IBCPackTrack.Web.ViewModels; >>>>using System; >>>>using System.IO; >>>>using System.Linq; >>>>using System.Web; >>>>using System.Web.Mvc; >>>> >>>>namespace IBCPackTrack.Web.Controllers >>>>{ >>>> public class RunSheetDetailsController : Controller >>>> { >>>> private ApplicationUnit _unit = new ApplicationUnit(); >>>> >>>> //[AllowAnonymous] >>>> public ActionResult Index() >>>> { >>>> RunSheetDetailsListViewModel vm = new RunSheetDetailsListViewModel(); >>>> var query = this._unit.RunSheetDetails.GetAll(); //.GetAll().OrderBy(rnh => rnh.Route.rte_name); >>>> vm.RunSheetDetails = query.ToList(); >>>> >>>> return View("Index", vm); >>>> } >>>> >>>> [ActionName("Edit")] >>>> public ActionResult Get(Guid id) >>>> { >>>> RunSheetDetailViewModel vm = new RunSheetDetailViewModel(); >>>> >>>> vm.RunSheetDetail = this._unit.RunSheetDetails.GetById(id); >>>> >>>> if (vm.RunSheetDetail != null) >>>> { >>>> return View("RunSheetDetail", vm); >>>> } >>>> >>>> } >>>>}>>>>
using System; >>>>using System.Collections.Generic; >>>>using System.Linq; >>>>using System.Net; >>>>using System.Net.Http; >>>>using System.Web.Http; >>>> >>>>using IBCPackTrack.Data; >>>>using IBCPackTrack.Models; >>>>using System.Data.Entity.Infrastructure; >>>> >>>>namespace IBCPackTrack.Web.Controllers >>>>{ >>>> //[Authorize] >>>> public class RunSheetDetailsAPIController : ApiController >>>> { >>>> private ApplicationUnit _unit = new ApplicationUnit(); >>>> >>>> [HttpGet] >>>> //[AllowAnonymous] >>>> public IEnumerable<RunSheetDetail> Get() >>>> { >>>> return this._unit.RunSheetDetails.GetAll(); >>>> } >>>> >>>> [HttpGet] >>>> public IEnumerable<RunSheetDetail> Get(Guid id) >>>> { >>>> return this._unit.RunSheetDetails.GetByRunSheetId(id); >>>> } >>>> } >>>>}>>>>
<a class="btn btn-primary btn-mini" data-bind="attr: {href: '/runsheetdetails/' + rnh_pk}">Select</a>>>>>
config.Routes.MapHttpRoute( >>>> name: "APIrnd", >>>> routeTemplate: "api/runsheetdetails/{id}", >>>> defaults: new >>>> { >>>> controller = "RunSheetDetailsAPI", >>>> id = RouteParameter.Optional >>>> }); >>>> >>>> config.Routes.MapHttpRoute( >>>> name: "DefaultApi", >>>> routeTemplate: "api/{controller}/{id}", >>>> defaults: new { id = RouteParameter.Optional }>>>>
config.Routes.MapHttpRoute( > name: "DefaultMVC", > routeTemplate: "{controller}/{action}/{id}", > defaults: new { action = "Index", id = RouteParameter.Optional }>Then, your RunSheetDetailsAPI urls would be http://servername/api/routsheetdetails/id, and your RunSheetDetails MVC urls would be http://servername/routsheetdetails and http://servername/routsheetdetails/edit/id for your index and edit pages respectively. Note that both the route template and url include "api" for your API controllers.