public override Member ToModel(Member member) { //Call base converter first base.ToModel(member); var contact = member as Contact; if (contact != null) { contact.FirstName = FirstName; contact.MiddleName = MiddleName; contact.LastName = LastName; contact.BirthDate = BirthDate; contact.DefaultLanguage = DefaultLanguage; contact.FullName = FullName; contact.Salutation = Salutation; contact.TimeZone = TimeZone; contact.TaxPayerId = TaxpayerId; contact.PreferredCommunication = PreferredCommunication; contact.PreferredDelivery = PreferredDelivery; contact.PhotoUrl = PhotoUrl; contact.Organizations = MemberRelations.Select(x => x.Ancestor).OfType <OrganizationEntity>().Select(x => x.Id).ToList(); contact.Name = contact.FullName; } return(member); }
public override Member ToModel(Member member) { //Call base converter first base.ToModel(member); if (member is Employee employee) { employee.FirstName = FirstName; employee.MiddleName = MiddleName; employee.LastName = LastName; employee.BirthDate = BirthDate; employee.DefaultLanguage = DefaultLanguage; employee.FullName = FullName; employee.IsActive = IsActive; employee.EmployeeType = Type; employee.TimeZone = TimeZone; employee.PhotoUrl = PhotoUrl; employee.Organizations = MemberRelations .Where(x => x.RelationType == RelationType.Membership.ToString()) .Select(x => x.Ancestor) .OfType <OrganizationEntity>() .Select(x => x.Id) .ToList(); } return(member); }
public override Member ToModel(Member member) { //Call base converter first base.ToModel(member); var employee = member as Employee; if (employee != null) { employee.Organizations = MemberRelations.Select(x => x.Ancestor).OfType<OrganizationDataEntity>().Select(x => x.Id).ToList(); } return member; }
public virtual void Patch(MemberEntity target) { target.Name = Name; target.MemberType = MemberType; target.OuterId = OuterId; target.Status = Status; if (!Phones.IsNullCollection()) { var phoneComparer = AnonymousComparer.Create((PhoneEntity x) => x.Number); Phones.Patch(target.Phones, phoneComparer, (sourcePhone, targetPhone) => targetPhone.Number = sourcePhone.Number); } if (!Emails.IsNullCollection()) { var addressComparer = AnonymousComparer.Create((EmailEntity x) => x.Address); Emails.Patch(target.Emails, addressComparer, (sourceEmail, targetEmail) => targetEmail.Address = sourceEmail.Address); } if (!Groups.IsNullCollection()) { var groupComparer = AnonymousComparer.Create((MemberGroupEntity x) => x.Group); Groups.Patch(target.Groups, groupComparer, (sourceGroup, targetGroup) => targetGroup.Group = sourceGroup.Group); } if (!Addresses.IsNullCollection()) { Addresses.Patch(target.Addresses, (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress)); } if (!Notes.IsNullCollection()) { var noteComparer = AnonymousComparer.Create((NoteEntity x) => x.Id ?? x.Body); Notes.Patch(target.Notes, noteComparer, (sourceNote, targetNote) => sourceNote.Patch(targetNote)); } if (!MemberRelations.IsNullCollection()) { var relationComparer = AnonymousComparer.Create((MemberRelationEntity x) => x.AncestorId); MemberRelations.Patch(target.MemberRelations, relationComparer, (sourceRel, targetRel) => { /*Nothing todo*/ }); } if (!SeoInfos.IsNullCollection()) { SeoInfos.Patch(target.SeoInfos, (sourceSeoInfo, targetSeoInfo) => sourceSeoInfo.Patch(targetSeoInfo)); } if (!DynamicPropertyObjectValues.IsNullCollection()) { DynamicPropertyObjectValues.Patch(target.DynamicPropertyObjectValues, (sourceDynamicPropertyObjectValues, targetDynamicPropertyObjectValues) => sourceDynamicPropertyObjectValues.Patch(targetDynamicPropertyObjectValues)); } }
public override Member ToModel(Member member) { //Call base converter first base.ToModel(member); var contact = member as Contact; if (contact != null) { contact.Organizations = MemberRelations.Select(x => x.Ancestor).OfType <OrganizationDataEntity>().Select(x => x.Id).ToList(); member.Name = contact.FullName; } return(member); }
public override Member ToModel(Member member) { //Call base converter first base.ToModel(member); var organization = member as Organization; if (organization != null && MemberRelations.Any()) { organization.ParentId = MemberRelations.FirstOrDefault().AncestorId; } return(member); }
/// <summary> /// This method used to convert data type instance to domain model /// </summary> public override Member ToModel(Member member) { // Here you can write code for custom mapping. // Member properties will be mapped in base method implementation by using value injection var retVal = base.ToModel(member) as Supplier; if (retVal != null) { retVal.Organizations = MemberRelations.Select(x => x.Ancestor).OfType <OrganizationDataEntity>().Select(x => x.Id).ToList(); retVal.Reviews = Reviews.Select(x => x.ToModel(AbstractTypeFactory <SupplierReview> .TryCreateInstance())).ToList(); } return(retVal); }
public override Member ToModel(Member member) { //Call base converter first base.ToModel(member); if (member is Organization organization) { organization.Description = Description; organization.OwnerId = OwnerId; organization.BusinessCategory = BusinessCategory; if (MemberRelations.Any()) { organization.ParentId = MemberRelations .FirstOrDefault(x => x.RelationType == RelationType.Membership.ToString())? .AncestorId; } } return(member); }
public override Member ToModel(Member member) { //Call base converter first base.ToModel(member); var organization = member as Organization; if (organization != null) { organization.Description = Description; organization.OwnerId = OwnerId; organization.BusinessCategory = BusinessCategory; if (MemberRelations.Any()) { organization.ParentId = MemberRelations.FirstOrDefault().AncestorId; } } return(member); }
public virtual void Patch(MemberDataEntity target) { target.Name = Name; if (!Phones.IsNullCollection()) { var phoneComparer = AnonymousComparer.Create((PhoneDataEntity x) => x.Number); Phones.Patch(target.Phones, phoneComparer, (sourcePhone, targetPhone) => targetPhone.Number = sourcePhone.Number); } if (!Emails.IsNullCollection()) { var addressComparer = AnonymousComparer.Create((EmailDataEntity x) => x.Address); Emails.Patch(target.Emails, addressComparer, (sourceEmail, targetEmail) => targetEmail.Address = sourceEmail.Address); } if (!Groups.IsNullCollection()) { var groupComparer = AnonymousComparer.Create((MemberGroupDataEntity x) => x.Group); Groups.Patch(target.Groups, groupComparer, (sourceGroup, targetGroup) => targetGroup.Group = sourceGroup.Group); } if (!Addresses.IsNullCollection()) { Addresses.Patch(target.Addresses, (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress)); } if (!Notes.IsNullCollection()) { var noteComparer = AnonymousComparer.Create((NoteDataEntity x) => x.Id ?? x.Body); Notes.Patch(target.Notes, noteComparer, (sourceNote, targetNote) => sourceNote.Patch(targetNote)); } if (!MemberRelations.IsNullCollection()) { var relationComparer = AnonymousComparer.Create((MemberRelationDataEntity x) => x.AncestorId); MemberRelations.Patch(target.MemberRelations, relationComparer, (sourceRel, targetRel) => { /*Nothing todo*/ }); } }
public override Member ToModel(Member member) { //Call base converter first base.ToModel(member); if (member is Contact contact) { contact.FirstName = FirstName; contact.MiddleName = MiddleName; contact.LastName = LastName; contact.BirthDate = BirthDate; contact.DefaultLanguage = DefaultLanguage; contact.FullName = FullName; contact.Salutation = Salutation; contact.TimeZone = TimeZone; contact.TaxPayerId = TaxpayerId; contact.PreferredCommunication = PreferredCommunication; contact.PreferredDelivery = PreferredDelivery; contact.DefaultShippingAddressId = DefaultShippingAddressId; contact.DefaultBillingAddressId = DefaultBillingAddressId; contact.PhotoUrl = PhotoUrl; contact.Organizations = MemberRelations .Where(x => x.RelationType == RelationType.Membership.ToString()) .Select(x => x.Ancestor) .OfType <OrganizationEntity>() .Select(x => x.Id) .ToList(); contact.AssociatedOrganizations = MemberRelations .Where(x => x.RelationType == RelationType.Association.ToString()) .Select(x => x.Ancestor) .OfType <OrganizationEntity>() .Select(x => x.Id) .ToList(); contact.Name = contact.FullName; } return(member); }
public override MemberEntity FromModel(Member member, PrimaryKeyResolvingMap pkMap) { if (member is Contact contact) { FirstName = contact.FirstName; MiddleName = contact.MiddleName; LastName = contact.LastName; BirthDate = contact.BirthDate; DefaultLanguage = contact.DefaultLanguage; FullName = contact.FullName; Salutation = contact.Salutation; TimeZone = contact.TimeZone; TaxpayerId = contact.TaxPayerId; PreferredCommunication = contact.PreferredCommunication; PreferredDelivery = contact.PreferredDelivery; DefaultShippingAddressId = contact.DefaultShippingAddressId; DefaultBillingAddressId = contact.DefaultBillingAddressId; PhotoUrl = contact.PhotoUrl; if (string.IsNullOrEmpty(Name)) { Name = contact.FullName; } if (contact.Organizations != null) { if (MemberRelations.IsNullCollection()) { MemberRelations = new ObservableCollection <MemberRelationEntity>(); } foreach (var organization in contact.Organizations) { var memberRelation = AbstractTypeFactory <MemberRelationEntity> .TryCreateInstance(); memberRelation.AncestorId = organization; memberRelation.AncestorSequence = 1; memberRelation.DescendantId = Id; memberRelation.RelationType = RelationType.Membership.ToString(); MemberRelations.Add(memberRelation); } } if (contact.AssociatedOrganizations != null) { if (MemberRelations.IsNullCollection()) { MemberRelations = new ObservableCollection <MemberRelationEntity>(); } foreach (var organization in contact.AssociatedOrganizations) { var memberRelation = AbstractTypeFactory <MemberRelationEntity> .TryCreateInstance(); memberRelation.AncestorId = organization; memberRelation.AncestorSequence = 1; memberRelation.DescendantId = Id; memberRelation.RelationType = RelationType.Association.ToString(); MemberRelations.Add(memberRelation); } } } //Call base converter return(base.FromModel(member, pkMap)); }