This commit is contained in:
2023-07-31 08:50:05 +03:00
parent cca943f37d
commit c5d9ae7b93
49 changed files with 546 additions and 398 deletions
@@ -3,14 +3,33 @@
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()
{
CreateMap<User, UserDto>();
MapUser();
MapAccount();
MapCurrency();
MapItems();
CreateMap<Motion, MotionDto>();
}
private void MapUser()
{
CreateMap<User, UserDto>();
}
private void MapAccount()
{
CreateMap<Account, AccountDto>()
.ForMember(x => x.HasMotions, o => o.MapFrom(x => x.Motions!.Any()))
.ForMember(x => x.CurrentUserId, o => o.MapFrom<UserIdResolver>())
@@ -45,4 +64,24 @@ public class AccountServiceProfile : Profile
.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()))
;
}
}