#377 Create a sample API.

pull/570/head
Halil ibrahim Kalkan 7 years ago
parent 58f2502c39
commit 96ee0b0436

3
.gitignore vendored

@ -276,4 +276,5 @@ templates/mvc/src/MyCompanyName.MyProjectName.Web/Logs/*.*
# macOS
.DS_Store
abp_io/src/Volo.AbpWebSite.Web/Logs/*
abp_io/src/Volo.AbpWebSite.Web/wwwroot/files/*
abp_io/src/Volo.AbpWebSite.Web/wwwroot/files/*
templates/service/host/MyCompanyName.MyProjectName.Host/Logs/logs.txt

@ -0,0 +1,10 @@
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
namespace MyCompanyName.MyProjectName.Todos
{
public interface ITodoAppService
{
Task<PagedResultDto<TodoDto>> GetListAsync();
}
}

@ -0,0 +1,10 @@
using System;
using Volo.Abp.Application.Dtos;
namespace MyCompanyName.MyProjectName.Todos
{
public class TodoDto : EntityDto<Guid>
{
public string Text { get; set; }
}
}

@ -0,0 +1,21 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace MyCompanyName.MyProjectName.Todos
{
public class TodoAppService : ApplicationService, ITodoAppService
{
public Task<PagedResultDto<TodoDto>> GetListAsync()
{
return Task.FromResult(
new PagedResultDto<TodoDto>(2, new List<TodoDto>
{
new TodoDto {Id = GuidGenerator.Create(), Text = "Todo item one"},
new TodoDto {Id = GuidGenerator.Create(), Text = "Todo item two"}
}
));
}
}
}

@ -0,0 +1,28 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
namespace MyCompanyName.MyProjectName.Todos
{
[RemoteService]
[Area("MyProjectName")]
[Route("api/MyProjectName/todos")]
public class TodosController : AbpController
{
private readonly ITodoAppService _todoAppService;
public TodosController(ITodoAppService todoAppService)
{
_todoAppService = todoAppService;
}
[HttpGet]
[Route("")]
public Task<PagedResultDto<TodoDto>> GetListAsync()
{
return _todoAppService.GetListAsync();
}
}
}
Loading…
Cancel
Save