namespace MyOffice.Services.Mapper; using Account.Domain; using AutoMapper; using Data.Models.Accounts; using Data.Models.Users; public class AccountServiceProfile : Profile { public AccountServiceProfile() { CreateMap(); CreateMap() .ForMember(x => x.HasMotions, o => o.MapFrom(x => x.Motions!.Any())) .ForMember(x => x.CurrentUserId, o => o.MapFrom()) .ForMember(x => x.Type, o => o.MapFrom((src, dst) => src.AccessRights!.FirstOrDefault(x => x.UserId == dst.CurrentUserId)!.Type.ToString())) ; CreateMap(); CreateMap(); CreateMap(); CreateMap() .ForMember(x => x.Id, o => o.MapFrom(x => x.Id)) .ForMember(x => x.AllowDelete, o => o.MapFrom(x => !x.Accounts!.Any())) ; } }