public string GetRegistrationStatus()
        {
            var reg = UserOrganisations.OrderBy(uo => uo.PINConfirmedDate)
                      .FirstOrDefault(uo => uo.PINConfirmedDate != null);

            if (reg != null)
            {
                return($"Registered {reg.PINConfirmedDate?.ToFriendly(false)}");
            }

            reg = UserOrganisations.OrderBy(uo => uo.PINConfirmedDate)
                  .FirstOrDefault(uo => uo.PINSentDate != null && uo.PINConfirmedDate == null);
            if (reg != null)
            {
                return("Awaiting PIN");
            }

            reg = UserOrganisations.OrderBy(uo => uo.PINConfirmedDate)
                  .FirstOrDefault(uo =>
                                  uo.PINSentDate == null && uo.PINConfirmedDate == null && uo.Method == RegistrationMethods.Manual);
            if (reg != null)
            {
                return("Awaiting Approval");
            }

            return("No registrations");
        }
Beispiel #2
0
        public string GetRegistrationStatus()
        {
            UserOrganisation reg = UserOrganisations.OrderBy(uo => uo.PINConfirmedDate).FirstOrDefault(uo => uo.HasBeenActivated());

            if (reg != null)
            {
                return($"Registered {reg.PINConfirmedDate?.ToFriendly(false)}");
            }

            reg = UserOrganisations.OrderBy(uo => uo.PINConfirmedDate)
                  .FirstOrDefault(uo => uo.IsAwaitingActivationPIN());
            if (reg != null)
            {
                return("Awaiting PIN");
            }

            reg = UserOrganisations.OrderBy(uo => uo.PINConfirmedDate)
                  .FirstOrDefault(uo => uo.IsAwaitingRegistrationApproval() && uo.Method == RegistrationMethods.Manual);
            if (reg != null)
            {
                return("Awaiting Approval");
            }

            return("No registrations");
        }
Beispiel #3
0
        /// <summary>
        ///     Returns true if organisation has been made an orphan and is in scope
        /// </summary>
        public bool GetIsOrphan()
        {
            DateTime pinExpiresDate = VirtualDateTime.Now.AddDays(0 - Global.PinInPostExpiryDays);

            return(Status == Core.OrganisationStatuses.Active &&
                   (GetCurrentScope().ScopeStatus == ScopeStatuses.InScope || GetCurrentScope().ScopeStatus == ScopeStatuses.PresumedInScope) &&
                   (UserOrganisations == null ||
                    !UserOrganisations.Any(
                        uo => uo.HasBeenActivated() ||
                        uo.Method == RegistrationMethods.Manual ||
                        uo.Method == RegistrationMethods.PinInPost &&
                        uo.PINSentDate.HasValue &&
                        uo.PINSentDate.Value > pinExpiresDate)));
        }
 public UserOrganisation GetLatestRegistration()
 {
     return(UserOrganisations.Where(uo => uo.PINConfirmedDate != null)
            .OrderByDescending(uo => uo.PINConfirmedDate)
            .FirstOrDefault());
 }
Beispiel #5
0
        public EmployerRecord ToEmployerRecord(long userId = 0)
        {
            OrganisationAddress address = null;

            if (userId > 0)
            {
                address = UserOrganisations.FirstOrDefault(uo => uo.UserId == userId)?.Address;
            }

            if (address == null)
            {
                address = GetLatestAddress();
            }

            if (address == null)
            {
                return(new EmployerRecord {
                    OrganisationId = OrganisationId,
                    SectorType = SectorType,
                    OrganisationName = OrganisationName,
                    NameSource = GetName()?.Source,
                    EmployerReference = EmployerReference,
                    DateOfCessation = DateOfCessation,
                    CompanyNumber = CompanyNumber,
                    SicSectors = GetSicSectorsString(null, ",<br/>"),
                    SicCodeIds = GetSicCodeIdsString(),
                    SicSource = GetSicSource(),
                    RegistrationStatus = GetRegistrationStatus(),
                    References = OrganisationReferences.ToDictionary(
                        r => r.ReferenceName,
                        r => r.ReferenceValue,
                        StringComparer.OrdinalIgnoreCase)
                });
            }

            return(new EmployerRecord {
                OrganisationId = OrganisationId,
                SectorType = SectorType,
                OrganisationName = OrganisationName,
                NameSource = GetName()?.Source,
                EmployerReference = EmployerReference,
                DateOfCessation = DateOfCessation,
                CompanyNumber = CompanyNumber,
                SicSectors = GetSicSectorsString(null, ",<br/>"),
                SicCodeIds = GetSicCodeIdsString(),
                SicSource = GetSicSource(),
                ActiveAddressId = address.AddressId,
                AddressSource = address.Source,
                Address1 = address.Address1,
                Address2 = address.Address2,
                Address3 = address.Address3,
                City = address.TownCity,
                County = address.County,
                Country = address.Country,
                PostCode = address.GetPostCodeInAllCaps(),
                PoBox = address.PoBox,
                IsUkAddress = address.IsUkAddress,
                RegistrationStatus = GetRegistrationStatus(),
                References = OrganisationReferences.ToDictionary(
                    r => r.ReferenceName,
                    r => r.ReferenceValue,
                    StringComparer.OrdinalIgnoreCase)
            });
        }
 public UserOrganisation GetFirstRegistration()
 {
     return(UserOrganisations.OrderBy(uo => uo.PINConfirmedDate)
            .FirstOrDefault(uo => uo.PINConfirmedDate > Created));
 }