66 lines
1.4 KiB
C#
66 lines
1.4 KiB
C#
namespace MyOffice.Services.Mapper;
|
|
|
|
using Account.Domain;
|
|
using AutoMapper;
|
|
using Data.Models.Accounts;
|
|
using Data.Models.Currencies;
|
|
using Data.Models.Items;
|
|
using Data.Models.Users;
|
|
using MyOffice.Services.Currency.Domain;
|
|
|
|
public class AccountServiceProfile : Profile
|
|
{
|
|
public AccountServiceProfile()
|
|
{
|
|
MapUser();
|
|
|
|
MapAccount();
|
|
|
|
MapCurrency();
|
|
|
|
MapItems();
|
|
|
|
CreateMap<Motion, MotionDto>();
|
|
}
|
|
|
|
private void MapUser()
|
|
{
|
|
CreateMap<User, UserDto>();
|
|
}
|
|
|
|
private void MapAccount()
|
|
{
|
|
CreateMap<AccountDetailed, AccountDetailedDto>();
|
|
|
|
CreateMap<AccountAccountCategory, AccountAccountCategoryDto>();
|
|
|
|
CreateMap<AccountCategory, AccountCategoryDto>()
|
|
.ForMember(x => x.Id, o => o.MapFrom(x => x.Id))
|
|
.ForMember(x => x.AllowDelete, o => o.MapFrom(x => !x.Accounts!.Any()))
|
|
;
|
|
|
|
CreateMap<AccountAccessInvite, AccountAccessInviteDto>()
|
|
.ForMember(x => x.Account, o => o.MapFrom(x => x.Account!.Name))
|
|
;
|
|
}
|
|
|
|
private void MapCurrency()
|
|
{
|
|
CreateMap<CurrencyGlobal, CurrencyGlobalDto>();
|
|
|
|
CreateMap<Currency, CurrencyDto>();
|
|
|
|
CreateMap<CurrencyRate, CurrencyRateDto>();
|
|
}
|
|
|
|
private void MapItems()
|
|
{
|
|
CreateMap<ItemCategory, ItemCategoryDto>();
|
|
|
|
CreateMap<Item, ItemDto>()
|
|
.ForMember(x => x.Id, o => o.MapFrom(x => x.ItemGlobalId))
|
|
.ForMember(x => x.Name, o => o.MapFrom(x => x.ItemGlobal.Name))
|
|
.ForMember(x => x.AllowDelete, o => o.MapFrom(x => !x.Motions!.Any()))
|
|
;
|
|
}
|
|
} |