Browse Source

Remove services prefix for all services.

pull/96/head
Halil İbrahim Kalkan 9 years ago
parent
commit
32518df791
  1. 11
      src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs
  2. 16
      test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/PersonAppService_Tests.cs

11
src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs

@ -78,6 +78,12 @@ namespace Volo.Abp.AspNetCore.Mvc
protected virtual void ConfigureParameters(ControllerModel controller) protected virtual void ConfigureParameters(ControllerModel controller)
{ {
/* Default binding system of Asp.Net Core for a parameter
* 1. Form values
* 2. Route values.
* 3. Query string.
*/
foreach (var action in controller.Actions) foreach (var action in controller.Actions)
{ {
foreach (var prm in action.Parameters) foreach (var prm in action.Parameters)
@ -250,7 +256,10 @@ namespace Volo.Abp.AspNetCore.Mvc
protected virtual AttributeRouteModel CreateAbpServiceAttributeRouteModel(string moduleName, string controllerName, ActionModel action, string httpMethod) protected virtual AttributeRouteModel CreateAbpServiceAttributeRouteModel(string moduleName, string controllerName, ActionModel action, string httpMethod)
{ {
var url = $"api/services/{moduleName}/{controllerName}/{action.ActionName}"; var url = $"api/{moduleName}/{controllerName}/{action.ActionName}";
return new AttributeRouteModel(new RouteAttribute(url)); return new AttributeRouteModel(new RouteAttribute(url));
} }

16
test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/PersonAppService_Tests.cs

@ -35,7 +35,7 @@ namespace Volo.Abp.AspNetCore.Mvc
public async Task GetAll_Test() public async Task GetAll_Test()
{ {
//Ideally should be [GET] /api/app/person //Ideally should be [GET] /api/app/person
var result = await GetResponseAsObjectAsync<ListResultDto<PersonDto>>("/api/services/app/person/GetAll"); var result = await GetResponseAsObjectAsync<ListResultDto<PersonDto>>("/api/app/person/GetAll");
result.Items.Count.ShouldBeGreaterThan(0); result.Items.Count.ShouldBeGreaterThan(0);
} }
@ -45,7 +45,7 @@ namespace Volo.Abp.AspNetCore.Mvc
var firstPerson = _personRepository.GetList().First(); var firstPerson = _personRepository.GetList().First();
//Ideally should be [GET] /api/app/person/{id} //Ideally should be [GET] /api/app/person/{id}
var result = await GetResponseAsObjectAsync<PersonDto>("/api/services/app/person/Get?id=" + firstPerson.Id); var result = await GetResponseAsObjectAsync<PersonDto>("/api/app/person/Get?id=" + firstPerson.Id);
result.Name.ShouldBe(firstPerson.Name); result.Name.ShouldBe(firstPerson.Name);
} }
@ -55,7 +55,7 @@ namespace Volo.Abp.AspNetCore.Mvc
var firstPerson = _personRepository.GetList().First(); var firstPerson = _personRepository.GetList().First();
//Ideally should be [DELETE] /api/app/person/{id} //Ideally should be [DELETE] /api/app/person/{id}
await Client.DeleteAsync("/api/services/app/person/Delete?id=" + firstPerson.Id); await Client.DeleteAsync("/api/app/person/Delete?id=" + firstPerson.Id);
(await _personRepository.FindAsync(firstPerson.Id)).ShouldBeNull(); (await _personRepository.FindAsync(firstPerson.Id)).ShouldBeNull();
} }
@ -69,7 +69,7 @@ namespace Volo.Abp.AspNetCore.Mvc
//Ideally should be [POST] /api/app/person //Ideally should be [POST] /api/app/person
var response = await Client.PostAsync( var response = await Client.PostAsync(
"/api/services/app/person/Create", "/api/app/person/Create",
new StringContent(postData, Encoding.UTF8, "application/json") new StringContent(postData, Encoding.UTF8, "application/json")
); );
@ -102,7 +102,7 @@ namespace Volo.Abp.AspNetCore.Mvc
//Ideally should be [PUT] /api/app/person/{id} //Ideally should be [PUT] /api/app/person/{id}
var response = await Client.PutAsync( var response = await Client.PutAsync(
"/api/services/app/person/Update?id=" + updateDto.Id, "/api/app/person/Update?id=" + updateDto.Id,
new StringContent(putData, Encoding.UTF8, "application/json") new StringContent(putData, Encoding.UTF8, "application/json")
); );
@ -136,7 +136,7 @@ namespace Volo.Abp.AspNetCore.Mvc
//Ideally should be [POST] /api/people/{id}/phones //Ideally should be [POST] /api/people/{id}/phones
var response = await Client.PostAsync( var response = await Client.PostAsync(
"/api/services/app/person/AddPhone?id=" + personToAddNewPhone.Id, "/api/app/person/AddPhone?id=" + personToAddNewPhone.Id,
new StringContent(postData, Encoding.UTF8, "application/json") new StringContent(postData, Encoding.UTF8, "application/json")
); );
@ -160,7 +160,7 @@ namespace Volo.Abp.AspNetCore.Mvc
var douglas = _personRepository.GetList().First(p => p.Name == "Douglas"); var douglas = _personRepository.GetList().First(p => p.Name == "Douglas");
//Ideally should be [GET] /api/person/{id}/phones?type=office //Ideally should be [GET] /api/person/{id}/phones?type=office
var result = await GetResponseAsObjectAsync<ListResultDto<PhoneDto>>("/api/services/app/person/GetPhones?id=" + douglas.Id); var result = await GetResponseAsObjectAsync<ListResultDto<PhoneDto>>("/api/app/person/GetPhones?id=" + douglas.Id);
result.Items.Count.ShouldBe(douglas.Phones.Count); result.Items.Count.ShouldBe(douglas.Phones.Count);
} }
@ -171,7 +171,7 @@ namespace Volo.Abp.AspNetCore.Mvc
var firstPhone = douglas.Phones.First(); var firstPhone = douglas.Phones.First();
//Ideally should be [DELETE] /api/app/person/{id} //Ideally should be [DELETE] /api/app/person/{id}
await Client.DeleteAsync("/api/services/app/person/DeletePhone?id=" + douglas.Id + "&phoneId=" + firstPhone.Id); await Client.DeleteAsync("/api/app/person/DeletePhone?id=" + douglas.Id + "&phoneId=" + firstPhone.Id);
douglas = _personRepository.GetList().First(p => p.Name == "Douglas"); douglas = _personRepository.GetList().First(p => p.Name == "Douglas");
douglas.Phones.Any(p => p.Id == firstPhone.Id).ShouldBeFalse(); douglas.Phones.Any(p => p.Id == firstPhone.Id).ShouldBeFalse();

Loading…
Cancel
Save