SKE-39 getAllCompetitionCategories - method on server

This commit is contained in:
Przemysław Stawujak 2018-12-03 22:10:32 +01:00
parent e13a951ded
commit 4bb63859d2
3 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,29 @@
using Abp.Authorization;
using Abp.Domain.Repositories;
using System.Collections.Generic;
using System.Linq;
using SystemKonkursow.Competition.CompetitionCategory.Dto;
namespace SystemKonkursow.Competition.CompetitionCategory
{
public class CompetitionCategoryAppService : SystemKonkursowAppServiceBase
{
private readonly IRepository<Domain.CompetitionCategory, int> _competitionCategoryRepository;
public CompetitionCategoryAppService(IRepository<Domain.CompetitionCategory, int> competitionCategoryRepository)
{
_competitionCategoryRepository = competitionCategoryRepository;
}
[AbpAuthorize]
public List<CompetitionCategoryDto> GetAllCompetitionCategories()
{
var competitionCategories = _competitionCategoryRepository.GetAll().ToList();
var mappedObjects = ObjectMapper.Map<List<CompetitionCategoryDto>>(competitionCategories
.OrderBy(t => t.Name));
return mappedObjects;
}
}
}

View File

@ -0,0 +1,9 @@
using Abp.Application.Services.Dto;
namespace SystemKonkursow.Competition.CompetitionCategory.Dto
{
public class CompetitionCategoryDto : EntityDto<int>
{
public string Name { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using AutoMapper;
namespace SystemKonkursow.Competition.CompetitionCategory.Dto
{
public class CompetitionCategoryMapProfile : Profile
{
public CompetitionCategoryMapProfile()
{
CreateMap<Domain.CompetitionCategory, CompetitionCategoryDto>();
}
}
}