public CompliancesVerificationDto GetCompliancesVerificationDetailProofofCompliance(string userId) { var user = Repository.Query<TeleConsult.Domain.User>().FirstOrDefault(a => a.Id.ToString() == userId); if (user != null) { var result = new CompliancesVerificationDto() { UserId = user.Id.ToString(), FirstName = user.FirstName, LastName = user.LastName, EmailAddress = user.Email, UserName = user.UserName, Avatar = user.Avatar }; var compliances = new List<Compliances>(); if (user.Profiles != null && user.Profiles.Any()) { foreach (var item in user.Profiles) { if (item.Specializations != null && item.Specializations.Any()) { foreach (var itemSpecialization in item.Specializations) { if (itemSpecialization.ExpiredDate == null) { compliances.Add(new Compliances() { Id = itemSpecialization.Id.ToString(), ExpiredDate = null, Name = itemSpecialization.Name, Status = CompliancesVerificationStatus.Unverified.ToString(), }); } else if (itemSpecialization.ExpiredDate < DateTime.Now) { compliances.Add(new Compliances() { Id = itemSpecialization.Id.ToString(), ExpiredDate = itemSpecialization.ExpiredDate, Name = itemSpecialization.Name, Status = CompliancesVerificationStatus.Expired.ToString(), }); } else { compliances.Add(new Compliances() { Id = itemSpecialization.Id.ToString(), ExpiredDate = itemSpecialization.ExpiredDate, Name = itemSpecialization.Name, Status = CompliancesVerificationStatus.Verified.ToString(), }); } } } } } result.Compliances = compliances; return result; } return null; }
public CompliancesVerificationDto GetCompliancesVerificationDetail(Guid userId) { var user = Repository.FindById<TeleConsult.Domain.User>(userId); try { CompliancesVerificationDto result = new CompliancesVerificationDto() { UserId = user.Id.ToString(), FirstName = user.FirstName, LastName = user.LastName, EmailAddress = user.Email, UserName = user.UserName, Avatar = user.Avatar }; // Profile var profile = user.Profiles.FirstOrDefault(); result.BusinessReferenceId = !string.IsNullOrEmpty(profile.BusinessName) ? profile.BusinessName : "N/A"; result.ShortDescription = !string.IsNullOrEmpty(profile.Description) ? profile.Description : "N/A"; result.DetailedBiography = !string.IsNullOrEmpty(profile.Biography) ? profile.Biography : "N/A"; result.Qualifications = !string.IsNullOrEmpty(profile.Qualification) ? profile.Qualification : "N/A"; // Location result.Location = BuildLocaltion(user.Locations.FirstOrDefault()); var workLocation = user.Locations.FirstOrDefault(); result.StreetNumber = !string.IsNullOrWhiteSpace(workLocation.StreetNumber) ? workLocation.StreetNumber : string.Empty; result.Street = !string.IsNullOrWhiteSpace(workLocation.Street) ? workLocation.Street : string.Empty; result.Suburb = !string.IsNullOrWhiteSpace(workLocation.Suburb) ? workLocation.Suburb : string.Empty; result.State = !string.IsNullOrWhiteSpace(workLocation.State) ? workLocation.State : string.Empty; result.Postcode = !string.IsNullOrWhiteSpace(workLocation.Postcode) ? workLocation.Postcode : string.Empty; result.Country = !string.IsNullOrWhiteSpace(workLocation.Country) ? workLocation.Country : string.Empty; var specializationList = new List<SpecializationCompliancesVerification>(); if (user.Profiles != null && user.Profiles.Any()) { if (user.Profiles[0].Specializations != null && user.Profiles[0].Specializations.Any()) { foreach (var itemSpecialization in user.Profiles[0].Specializations) { var specialization = new SpecializationCompliancesVerification(); // Set info for specialization specialization.Id = itemSpecialization.Id; specialization.ProfessionalOrTrade = !string.IsNullOrWhiteSpace(itemSpecialization.ProfessionalOrTrade) ? itemSpecialization.ProfessionalOrTrade : string.Empty; specialization.SpecialisationName = !string.IsNullOrWhiteSpace(itemSpecialization.Name) ? itemSpecialization.Name : string.Empty; specialization.ExpiredDate = itemSpecialization.ExpiredDate; specialization.LicenceToOperate = itemSpecialization.LicenceToOperate; if (specialization.LicenceToOperate) { if (specialization.ExpiredDate.HasValue) { if (specialization.ExpiredDate.Value >= DateTime.Now) { specialization.Status = VerifiedType.Verified.ToString(); } else { specialization.Status = VerifiedType.Expired.ToString(); } } else { specialization.Status = VerifiedType.Unverified.ToString(); } } else { specialization.Status = VerifiedType.Unlicense.ToString(); } // Permitted country var countryPermittedList = new List<CountriesPermittedCompliancesVerification>(); if (itemSpecialization.PermittedCountries != null && itemSpecialization.PermittedCountries.Any()) { var countryPermitted = new CountriesPermittedCompliancesVerification(); foreach (var cp in itemSpecialization.PermittedCountries) { countryPermitted.Name = !string.IsNullOrWhiteSpace(cp.Name) ? cp.Name : string.Empty; if (!string.IsNullOrWhiteSpace(cp.State) && !string.IsNullOrWhiteSpace(cp.RegulatoryAuthority)) { var stateAndRegulatoryList = new List<StateAndRegulatoryCompliancesVerification>(); var stateArr = cp.State.Split('_'); var regulatoryArr = cp.RegulatoryAuthority.Split('_'); for (int i = 0; i < stateArr.Count() - 1; i++) { // Add to stateAndRegulatoryList stateAndRegulatoryList.Add( new StateAndRegulatoryCompliancesVerification() { State = !string.IsNullOrWhiteSpace(stateArr[i]) ? stateArr[i] : string.Empty, RegulatoryAuthority = !string.IsNullOrWhiteSpace(regulatoryArr[i]) ? regulatoryArr[i] : string.Empty, }); } countryPermitted.StateAndRegulatory = stateAndRegulatoryList; } countryPermittedList.Add(countryPermitted); } // Add country permitted for specialisation specialization.CountriesPermitted = countryPermittedList; } // POCs var pocList = new List<POCCompliancesVerification>(); if (itemSpecialization.POCs != null && itemSpecialization.POCs.Any()) { foreach (var poc in itemSpecialization.POCs) { var pocItem = new POCCompliancesVerification() { Id = poc.Id, S3FileName = poc.S3FileName, OriginalFileName = poc.OriginalFileName }; // Add to pocList pocList.Add(pocItem); } // Add pocList to specialization specialization.POCs = pocList; } // Add specialization to list specializationList.Add(specialization); } } } result.Specialisation = specializationList; return result; } catch (Exception e) { Log.Error("CompliancesVerificationDto GetCompliancesVerificationDetail(string userId)", e); } return null; }