Skip to content

Commit 860693d

Browse files
committed
Working on jtable sample.
1 parent c85db1f commit 860693d

File tree

16 files changed

+178
-4
lines changed

16 files changed

+178
-4
lines changed

AbpWithjTable/AbpjTable.Application/AbpjTable.Application.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@
7070
<ItemGroup>
7171
<Compile Include="AbpjTableApplicationModule.cs" />
7272
<Compile Include="AbpjTableAppServiceBase.cs" />
73+
<Compile Include="Cities\CityAppService.cs" />
74+
<Compile Include="Cities\ComboboxItemDto.cs" />
75+
<Compile Include="Cities\Dto\CityDto.cs" />
76+
<Compile Include="Cities\ICityAppService.cs" />
77+
<Compile Include="People\Dto\CreatePersonInput.cs" />
78+
<Compile Include="People\Dto\CreatePersonOutput.cs" />
7379
<Compile Include="People\Dto\GetPeopleInput.cs" />
7480
<Compile Include="People\IPersonAppService.cs" />
7581
<Compile Include="People\PersonAppService.cs" />

AbpWithjTable/AbpjTable.Application/AbpjTableApplicationModule.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.Reflection;
22
using Abp.Modules;
3+
using AbpjTable.Cities;
4+
using AbpjTable.Cities.Dto;
35
using AbpjTable.People;
46
using AbpjTable.People.Dto;
57
using AutoMapper;
@@ -14,6 +16,8 @@ public override void Initialize()
1416
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
1517

1618
Mapper.CreateMap<Person, PersonDto>();
19+
Mapper.CreateMap<City, CityDto>();
20+
Mapper.CreateMap<CreatePersonInput, Person>();
1721
}
1822
}
1923
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Abp.Application.Services.Dto;
2+
using Abp.Domain.Repositories;
3+
4+
namespace AbpjTable.Cities
5+
{
6+
public class CityAppService : ICityAppService
7+
{
8+
private readonly IRepository<City> _cityRepository;
9+
10+
public CityAppService(IRepository<City> cityRepository)
11+
{
12+
_cityRepository = cityRepository;
13+
}
14+
15+
public ListResultOutput<ComboboxItemDto> GetAllCities()
16+
{
17+
return new ListResultOutput<ComboboxItemDto>
18+
{
19+
Items = _cityRepository.GetAllList().ConvertAll(c => new ComboboxItemDto(c.Id.ToString(), c.Name))
20+
};
21+
}
22+
}
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Abp.Application.Services.Dto;
2+
3+
namespace AbpjTable.Cities
4+
{
5+
public class ComboboxItemDto : IDto //TODO: Move to ABP!
6+
{
7+
public string Value { get; set; }
8+
9+
public string DisplayText { get; set; }
10+
11+
public ComboboxItemDto()
12+
{
13+
14+
}
15+
16+
public ComboboxItemDto(string value, string displayText)
17+
{
18+
Value = value;
19+
DisplayText = displayText;
20+
}
21+
}
22+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.ComponentModel.DataAnnotations;
2+
using Abp.Application.Services.Dto;
3+
4+
namespace AbpjTable.Cities.Dto
5+
{
6+
public class CityDto : EntityDto
7+
{
8+
[Required]
9+
public string Name { get; set; }
10+
}
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Abp.Application.Services;
2+
using Abp.Application.Services.Dto;
3+
4+
namespace AbpjTable.Cities
5+
{
6+
public interface ICityAppService : IApplicationService
7+
{
8+
ListResultOutput<ComboboxItemDto> GetAllCities();
9+
}
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Abp.Application.Services.Dto;
2+
3+
namespace AbpjTable.People.Dto
4+
{
5+
public class CreatePersonInput : PersonDto, IInputDto
6+
{
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Abp.Application.Services.Dto;
2+
3+
namespace AbpjTable.People.Dto
4+
{
5+
public class CreatePersonOutput : IOutputDto
6+
{
7+
public PersonDto Person { get; set; }
8+
}
9+
}

AbpWithjTable/AbpjTable.Application/People/IPersonAppService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ namespace AbpjTable.People
77
public interface IPersonAppService : IApplicationService
88
{
99
PagedResultOutput<PersonDto> GetPeople(GetPeopleInput input);
10+
11+
CreatePersonOutput CreatePerson(CreatePersonInput input);
1012
}
1113
}

AbpWithjTable/AbpjTable.Application/People/PersonAppService.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,17 @@ public PagedResultOutput<PersonDto> GetPeople(GetPeopleInput input)
3131
Items = Mapper.Map<List<PersonDto>>(personList)
3232
};
3333
}
34+
35+
public CreatePersonOutput CreatePerson(CreatePersonInput input)
36+
{
37+
var person = Mapper.Map<Person>(input);
38+
39+
_personRepository.InsertAndGetId(person);
40+
41+
return new CreatePersonOutput
42+
{
43+
Person = Mapper.Map<PersonDto>(person)
44+
};
45+
}
3446
}
3547
}

0 commit comments

Comments
 (0)