Search code examples
angularasp.net-coreaspnetboilerplate

AspnetBoilerpate REST Urls


After going through the documentation and also the github issues, I couldn't find a way to create RESTful apis. It only refers to use standard webapi implementation if we want to go RESTful.

Is there an alternative way(without completing re-writing current webapi implementation) to get the api's RESTful and at the same time get the serviceproxies to work with those?


Solution

  • You can create Restful API with Aspnet Boilerplate. Here's a sample to show you how to do it.

    public class TestAppService : SwagResterAppServiceBase, ITestAppService
    {
        [Route("api/services/app/Test")]
        [HttpPost]
        public Task CreateTest(TestDetailsDto input)
        {
            throw new NotImplementedException();
        }
    
        [Route("api/services/app/Test")]
        [HttpDelete]
        public Task DeleteTest(EntityDto input)
        {
            throw new NotImplementedException();
        }
    
        [Route("api/services/app/Test")]
        [HttpGet]
        public Task GetTest(EntityDto input)
        {
            throw new NotImplementedException();
        }
    
        [Route("api/services/app/Test")]
        [HttpPut]
        public Task UpdateTest(TestDetailsDto input)
        {
            throw new NotImplementedException();
        }
    }
    
    public interface ITestAppService: IApplicationService, ITransientDependency
    {
    
        Task CreateTest(TestDetailsDto input);
    
    
        Task DeleteTest(EntityDto input);
    
    
        Task GetTest(EntityDto input);
    
    
        Task UpdateTest(TestDetailsDto input);
    }
    
    public class TestDetailsDto
    {
    
    }
    

    Then run the refresh.bat to regenerate service proxies.

    Swagger Screen Shot Proof