public static void Patch(this AccountEntity source, AccountEntity target) { var patchInjection = new PatchInjection<AccountEntity>(x => x.UserType, x => x.AccountState, x => x.MemberId, x => x.StoreId, x => x.IsAdministrator); target.InjectFrom(patchInjection, source); if (!source.ApiAccounts.IsNullCollection()) { source.ApiAccounts.Patch(target.ApiAccounts, (sourceItem, targetItem) => sourceItem.Patch(targetItem)); } if (!source.RoleAssignments.IsNullCollection()) { source.RoleAssignments.Patch(target.RoleAssignments, (sourceItem, targetItem) => sourceItem.Patch(targetItem)); } }
public static AccountEntity ToDataModel(this ApplicationUserExtended user) { var retVal = new AccountEntity(); retVal.InjectFrom(user); retVal.AccountState = user.UserState.ToString(); if(user.Roles != null) { retVal.RoleAssignments = new ObservableCollection<RoleAssignmentEntity>(user.Roles.Select(x => x.ToAssignmentDataModel())); } if(user.ApiAccounts != null) { retVal.ApiAccounts = new ObservableCollection<ApiAccountEntity>(user.ApiAccounts.Select(x => x.ToDataModel())); } return retVal; }