public async Task <List <ChangeDescriptorDto> > GetModelChangesAsync(EstablishmentModel original, EstablishmentModel model, EstablishmentApprovalsPolicy approvalsPolicy)
        {
            var changes = ReflectionHelper.DetectChanges(model, original, new[] { typeof(IEBTModel), typeof(ProprietorModel) });

            changes.AddRange(await DetectAdditionalAddressChanges(original, model));
            changes.AddRange(await DetectProprietorsChanges(original, model));
            var retVal = new List <ChangeDescriptorDto>();

            var approvalFields = approvalsPolicy.GetFieldsRequiringApproval();

            foreach (var change in changes)
            {
                if (_cachedLookupService.IsLookupField(change.Name))
                {
                    change.OldValue = await _cachedLookupService.GetNameAsync(change.Name, change.OldValue.ToInteger());

                    change.NewValue = await _cachedLookupService.GetNameAsync(change.Name, change.NewValue.ToInteger());
                }

                if (change.DisplayName == null)
                {
                    change.DisplayName = PropertyName2Label(change.Name);
                }

                retVal.Add(new ChangeDescriptorDto
                {
                    Id               = change.Name,
                    Name             = change.DisplayName ?? change.Name,
                    NewValue         = change.NewValue.Clean(),
                    OldValue         = change.OldValue.Clean(),
                    Tag              = change.Tag,
                    RequiresApproval = (change.Tag == "additionaladdress" && approvalsPolicy.AdditionalAddresses.RequiresApproval) ||
                                       //(change.Tag == "proprietors" && approvalsPolicy.IEBTDetail.Proprietors.RequiresApproval) ||
                                       //(change.Name.Contains(nameof(approvalsPolicy.IEBTDetail.ChairOfProprietor)) && approvalsPolicy.IEBTDetail.ChairOfProprietor.RequiresApproval) ||
                                       approvalFields.Contains(change.Name, StringComparer.OrdinalIgnoreCase),
                    ApproverName = approvalsPolicy.GetApproverName(change.Name)
                });
            }

            await DetectSENChanges(original, model, retVal);

            return(retVal);
        }
        public async Task <List <ChangeDescriptorDto> > GetModelChangesAsync(EstablishmentModel model, EstablishmentApprovalsPolicy approvalsPolicy, IPrincipal principal)
        {
            var originalModel = (await GetAsync(model.Urn.Value, principal)).GetResult();

            return(await GetModelChangesAsync(originalModel, model, approvalsPolicy));
        }