Rest API Improvements #106: Can use Async in app service methods by hided from client url and proxies.

pull/112/head
Halil İbrahim Kalkan 8 years ago
parent 06b96677ba
commit ff4363dd61

@ -12,7 +12,9 @@ namespace Volo.Abp.AspNetCore.Mvc
return;
}
context.ActionNameInUrl = HttpMethodHelper.RemoveHttpMethodPrefix(context.ActionNameInUrl, context.HttpMethod);
context.ActionNameInUrl = HttpMethodHelper
.RemoveHttpMethodPrefix(context.ActionNameInUrl, context.HttpMethod)
.RemovePostFix("Async");
}
}
}

@ -72,7 +72,7 @@ namespace Volo.Abp.Application.Services
AsyncQueryableExecuter = DefaultAsyncQueryableExecuter.Instance;
}
public virtual async Task<TEntityDto> Get(TPrimaryKey id)
public virtual async Task<TEntityDto> GetAsync(TPrimaryKey id)
{
CheckGetPermission();
@ -80,7 +80,7 @@ namespace Volo.Abp.Application.Services
return MapToEntityDto(entity);
}
public virtual async Task<PagedResultDto<TEntityDto>> GetList(TGetAllInput input)
public virtual async Task<PagedResultDto<TEntityDto>> GetListAsync(TGetAllInput input)
{
CheckGetAllPermission();
@ -99,7 +99,7 @@ namespace Volo.Abp.Application.Services
);
}
public virtual async Task<TEntityDto> Create(TCreateInput input)
public virtual async Task<TEntityDto> CreateAsync(TCreateInput input)
{
CheckCreatePermission();
@ -111,7 +111,7 @@ namespace Volo.Abp.Application.Services
return MapToEntityDto(entity);
}
public virtual async Task<TEntityDto> Update(TPrimaryKey id, TUpdateInput input)
public virtual async Task<TEntityDto> UpdateAsync(TPrimaryKey id, TUpdateInput input)
{
CheckUpdatePermission();
@ -125,7 +125,7 @@ namespace Volo.Abp.Application.Services
return MapToEntityDto(entity);
}
public virtual Task Delete(TPrimaryKey id)
public virtual Task DeleteAsync(TPrimaryKey id)
{
CheckDeletePermission();

@ -37,14 +37,14 @@ namespace Volo.Abp.Application.Services
: IApplicationService
where TEntityDto : IEntityDto<TPrimaryKey>
{
Task<TEntityDto> Get(TPrimaryKey id);
Task<TEntityDto> GetAsync(TPrimaryKey id);
Task<PagedResultDto<TEntityDto>> GetList(TGetAllInput input);
Task<PagedResultDto<TEntityDto>> GetListAsync(TGetAllInput input);
Task<TEntityDto> Create(TCreateInput input);
Task<TEntityDto> CreateAsync(TCreateInput input);
Task<TEntityDto> Update(TPrimaryKey id, TUpdateInput input);
Task<TEntityDto> UpdateAsync(TPrimaryKey id, TUpdateInput input);
Task Delete(TPrimaryKey id);
Task DeleteAsync(TPrimaryKey id);
}
}

@ -1,7 +1,11 @@
namespace Volo.Abp.Http.DynamicProxying
using System.Threading.Tasks;
namespace Volo.Abp.Http.DynamicProxying
{
public interface IRegularTestController
{
int IncrementValue(int value);
Task<int> IncrementValueAsync(int value);
}
}

@ -28,7 +28,7 @@ namespace Volo.Abp.Http.DynamicProxying
{
var firstPerson = _personRepository.GetList().First();
var person = await _peopleAppService.Get(firstPerson.Id);
var person = await _peopleAppService.GetAsync(firstPerson.Id);
person.ShouldNotBeNull();
person.Id.ShouldBe(firstPerson.Id);
person.Name.ShouldBe(firstPerson.Name);
@ -37,7 +37,7 @@ namespace Volo.Abp.Http.DynamicProxying
[Fact]
public async Task GetList()
{
var people = await _peopleAppService.GetList(new PagedAndSortedResultRequestDto());
var people = await _peopleAppService.GetListAsync(new PagedAndSortedResultRequestDto());
people.TotalCount.ShouldBeGreaterThan(0);
people.Items.Count.ShouldBe(people.TotalCount);
}
@ -47,7 +47,7 @@ namespace Volo.Abp.Http.DynamicProxying
{
var firstPerson = _personRepository.GetList().First();
await _peopleAppService.Delete(firstPerson.Id);
await _peopleAppService.DeleteAsync(firstPerson.Id);
firstPerson = _personRepository.GetList().FirstOrDefault(p => p.Id == firstPerson.Id);
firstPerson.ShouldBeNull();
@ -58,7 +58,7 @@ namespace Volo.Abp.Http.DynamicProxying
{
var uniquePersonName = Guid.NewGuid().ToString();
var person = await _peopleAppService.Create(new PersonDto
var person = await _peopleAppService.CreateAsync(new PersonDto
{
Name = uniquePersonName,
Age = 42
@ -80,7 +80,7 @@ namespace Volo.Abp.Http.DynamicProxying
var firstPerson = _personRepository.GetList().First();
var uniquePersonName = Guid.NewGuid().ToString();
var person = await _peopleAppService.Update(
var person = await _peopleAppService.UpdateAsync(
firstPerson.Id,
new PersonDto
{

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Services;
using Volo.Abp.AspNetCore.Mvc;
@ -15,5 +16,12 @@ namespace Volo.Abp.Http.DynamicProxying
{
return value + 1;
}
[HttpGet]
[Route("increment")]
public Task<int> IncrementValueAsync(int value)
{
return Task.FromResult(value + 1);
}
}
}

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit;
@ -20,5 +21,11 @@ namespace Volo.Abp.Http.DynamicProxying
{
_controller.IncrementValue(42).ShouldBe(43);
}
[Fact]
public async Task IncrementValueAsync()
{
(await _controller.IncrementValueAsync(42)).ShouldBe(43);
}
}
}

@ -18,7 +18,7 @@ namespace Volo.Abp.TestApp.Application
[Fact]
public async Task GetAll()
{
var people = await _peopleAppService.GetList(new PagedAndSortedResultRequestDto());
var people = await _peopleAppService.GetListAsync(new PagedAndSortedResultRequestDto());
people.Items.Count.ShouldBeGreaterThan(0);
}
}

Loading…
Cancel
Save