public static string Status(ProfileStatus profileStatus) { switch (profileStatus) { case ProfileStatus.AccountCreated: return("0"); case ProfileStatus.Profiled: return("1"); case ProfileStatus.PhoneVerfiedOnly: return("2"); case ProfileStatus.EmailVerifiedOnly: return("3"); case ProfileStatus.PhonePlusEmailVerified: return("4"); case ProfileStatus.IncorrectEmail: return("5"); case ProfileStatus.AccountDisabled: return("404"); default: return(null); } }
protected IDictionary <ProfileStatus, int> GetPersonCount(DateTime date) { IDictionary <ProfileStatus, int> counts = new Dictionary <ProfileStatus, int>(); // get deleted profiles from Profiling1 audit trail - required because deletions due to person merges are only recorded there (and not in PRF_Person_AUD). IList <int> deleted = this.auditTasks.GetOldDeletedProfiles().Where(x => x.WhenDate.Value <= date).Select(x => Convert.ToInt32(x.PersonID)).ToList(); foreach (ProfileStatus ps in this.personTasks.GetAllProfileStatuses()) { // get list of persons according to envers at given date IList <Person> enversPersonList = this.auditTasks.GetPersons(date, ps); // filter out those that were deleted, but whose deletion wasn't recorded in PRF_Person_AUD table (REVTYPE=2). counts.Add(ps, enversPersonList.Where(x => !deleted.Contains(x.Id)).Count()); } // do the same as above, but for FARDC_2007_List ProfileStatus fardcPs = this.personTasks.GetProfileStatus(ProfileStatus.FARDC_2007_LIST); if (fardcPs != null) { IList <Person> fardcList = this.auditTasks.GetPersons(date, fardcPs); counts.Add(fardcPs, fardcList.Where(x => !deleted.Contains(x.Id)).Count()); } return(counts); }
protected IDictionary <ProfileStatus, int> GetCurrentPersonCount(ISession session) { IList <object[]> counts = this.personStatisticsQuery.GetLiveCreatedProfilesCount(session); IDictionary <ProfileStatus, int> dict = new Dictionary <ProfileStatus, int>(); foreach (ProfileStatus ps in this.personTasks.GetAllProfileStatuses(session)) { IEnumerable <object[]> psCounts = counts.Where(x => Convert.ToInt32(x[0]) == ps.Id); if (psCounts != null && psCounts.Any()) { object[] row = psCounts.First(); dict.Add(ps, Convert.ToInt32(row[1])); } else { dict.Add(ps, 0); } } ProfileStatus fardc2007List = this.personTasks.GetProfileStatus(ProfileStatus.FARDC_2007_LIST, session); IEnumerable <object[]> fardc2007Counts = counts.Where(x => Convert.ToInt32(x[0]) == fardc2007List.Id); if (fardc2007Counts != null && fardc2007Counts.Any()) { object[] row = fardc2007Counts.First(); dict.Add(fardc2007List, Convert.ToInt32(row[1])); } else { dict.Add(fardc2007List, 0); } return(dict); }
public async Task UpdateProfileUpdatesProfileInResultsCacheTest(ProfileStatus status) { var expected = Model.Create <UpdatableProfile>().Set(x => x.Status = status); var profile = Model.Create <Profile>().Set(x => x.BannedAt = null); var changeResult = Model.Create <ProfileChangeResult>().Set(x => x.ProfileChanged = true); var cacheResults = new List <ProfileResult> { Model.Create <ProfileResult>().Set(x => x.Id = profile.Id) }; var store = Substitute.For <IProfileStore>(); var calculator = Substitute.For <IProfileChangeCalculator>(); var processor = Substitute.For <IProfileChangeProcessor>(); var cache = Substitute.For <IProfileCache>(); var sut = new ProfileCommand(store, calculator, processor, cache); using (var tokenSource = new CancellationTokenSource()) { cache.GetProfileResults().Returns(cacheResults); store.GetProfile(profile.Id, tokenSource.Token).Returns(profile); calculator.CalculateChanges(profile, expected).Returns(changeResult); await sut.UpdateProfile(profile.Id, expected, tokenSource.Token).ConfigureAwait(false); // This is a mouthful. We want to make sure that the profile results being put into // the cache contains only a single item matching our updated profile and that has // all the same data as the updated profile cache.Received().StoreProfileResults( Verify.That <ICollection <ProfileResult> >( x => x.Single(y => y.Id == profile.Id) .Should().BeEquivalentTo(expected, opt => opt.ExcludingMissingMembers()))); } }
void ReportProfileChecked(IProfileDefinition profile, ProfileStatus status, string dump) { if (ProfileDefinitionCompleted != null) { ProfileDefinitionCompleted(profile, status, dump); } }
public async Task GetReturnsCategoryWithCorrectLinkCountWhenProfileIsHiddenAndThenRestoredTest( ProfileStatus status) { var account = Model.Create <Account>(); var profile = await Model.UsingBuildStrategy <ProfileBuildStrategy>().Create <Profile>().Set(x => x.Status = status) .Save(_logger, account).ConfigureAwait(false); var newCategory = profile.Skills.First(); var address = ApiLocation.Category(newCategory); var categoryApproval = new NewCategory { Group = CategoryGroup.Skill, Name = newCategory.Name }; await categoryApproval.Save(_logger).ConfigureAwait(false); var firstActual = await Client.Get <PublicCategory>(address, _logger).ConfigureAwait(false); firstActual.LinkCount.Should().Be(1); await profile.Set(x => x.Status = ProfileStatus.Hidden).Save(_logger, account).ConfigureAwait(false); var secondActual = await Client.Get <PublicCategory>(address, _logger).ConfigureAwait(false); secondActual.LinkCount.Should().Be(0); await profile.Set(x => x.Status = status).Save(_logger, account).ConfigureAwait(false); var thirdActual = await Client.Get <PublicCategory>(address, _logger).ConfigureAwait(false); thirdActual.LinkCount.Should().Be(1); }
public async Task <IActionResult> OnPostAsync(int id, ProfileStatus status) { var profile = await Context.Profile.FirstOrDefaultAsync( m => m.ProfileId == id); if (profile == null) { return(NotFound()); } var contactOperation = (status == ProfileStatus.Approved) ? ContactOperations.Approve : ContactOperations.Reject; var isAuthorized = await AuthorizationService.AuthorizeAsync(User, profile, contactOperation); if (!isAuthorized.Succeeded) { return(new ChallengeResult()); } profile.Status = status; Context.Profile.Update(profile); await Context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
void _td_ProfileDefinitionCompleted(IProfileDefinition profile, ProfileStatus status, string dump) { ProfileTestInfo info = new ProfileTestInfo(); info.Status = status; info.Log = dump; _profilesSupportInfo.Add(profile, info); }
public Account(int id, string name, string email, string user, string password, ProfileStatus profile) { Id = id; Name = name; Email = email; User = user; Password = password; Profile = profile; }
/// <summary> /// Checks profiles support (using algorithm defined in profile definition) /// </summary> /// <param name="profiles">List of profiles.</param> /// <param name="features">Supported features.</param> /// <param name="scopes">Scopes.</param> internal void CheckProfiles(IEnumerable <IProfileDefinition> profiles, IEnumerable <Feature> features, IEnumerable <string> scopes, Dictionary <string, object> parameters) { foreach (IProfileDefinition profile in profiles) { string dump = string.Empty; ProfileStatus status = profile.Check(out dump, features, scopes, parameters); ReportProfileChecked(profile, status, dump); } }
public IList <Person> GetPersons(DateTime date, ProfileStatus profileStatus) { int revision = this.GetRevisionNumberForDate(date); return(AuditReaderFactory.Get(Session).CreateQuery() .ForEntitiesAtRevision(typeof(Person), Convert.ToInt64(revision)) .Add(AuditEntity.Property("ProfileStatus").Eq(profileStatus)) .Add(AuditEntity.Property("Archive").Eq(false)) .GetResultList <Person>()); }
public override ProfileStatus Check(out string reason, System.Collections.Generic.IEnumerable <Feature> features, System.Collections.Generic.IEnumerable <string> scopes) { reason = string.Empty; StringBuilder sb = new StringBuilder(); ProfileStatus status = ProfileStatus.NotSupported; sb.AppendLine(string.Format("Check profile support for {0}", Name)); bool scopePresent = scopes.Contains(Scope); sb.AppendLine(string.Format("Scope {0}: \t\t{1}", Scope, scopePresent ? "PRESENT" : "NOT PRESENT")); if (!scopePresent) { sb.AppendFormat("Profile not supported"); } else { bool profileOk = true; bool supported; Action <Feature, string> checkNextMandatory = new Action <Feature, string>( (feature, displayName) => { supported = features.Contains(feature); LogMandatory(sb, displayName, supported); profileOk = profileOk && supported; }); Action <Feature, string> checkNextOptional = new Action <Feature, string>( (feature, displayName) => { supported = features.Contains(feature); LogOptional(sb, displayName, supported); }); checkNextMandatory(Feature.MediaService, "Media"); checkNextOptional(Feature.PTZService, "PTZ"); if (profileOk) { status = ProfileStatus.Supported; } else { status = ProfileStatus.Failed; } } reason = sb.ToString(); return(status); }
public void WithStatus_OriginalName_ShouldBe_Null_WhenValueIs_Synced() { // Arrange var profile = new Profile { OriginalName = "Profile name" }; const ProfileStatus value = ProfileStatus.Synced; // Act profile = profile.WithStatus(value); // Assert profile.OriginalName.Should().BeNull(); }
public void WithStatus_UniqueNameIndex_ShouldBe_Zero_WhenValueIs_Synced() { // Arrange var profile = new Profile { UniqueNameIndex = 5 }; const ProfileStatus value = ProfileStatus.Synced; // Act profile = profile.WithStatus(value); // Assert profile.UniqueNameIndex.Should().Be(0); }
public void WithStatus_Status_ShouldBe_Value() { // Arrange var profile = new Profile { Status = ProfileStatus.Created }; const ProfileStatus value = ProfileStatus.Synced; // Act profile = profile.WithStatus(value); // Assert profile.Status.Should().Be(value); }
public static Profile WithStatus(this Profile profile, ProfileStatus value) { var p = profile.Clone(); p.Status = value; if (value == ProfileStatus.Synced) { p.OriginalName = null; p.UniqueNameIndex = 0; } return(p); }
public void CalculateChangesCorrectlyIdentifiesChangesToStatusTest( ProfileStatus originalValue, ProfileStatus updatedValue, bool expected) { var original = Model.Create <Profile>().Set(x => x.Status = originalValue); var updated = original.Clone().Set(x => x.Status = updatedValue); var sut = new ProfileChangeCalculator(); var actual = sut.CalculateChanges(original, updated); actual.ProfileChanged.Should().Be(expected); }
CalculateChangesMarksProfileChangedWithNoCategoryChangesWhenStatusChangedBetweenAvailableAndUnavailableTest( ProfileStatus originalValue, ProfileStatus updatedValue) { var original = Model.Create <Profile>().Set(x => x.Status = originalValue); var updated = original.Clone().Set(x => x.Status = updatedValue); var sut = new ProfileChangeCalculator(); var actual = sut.CalculateChanges(original, updated); actual.ProfileChanged.Should().BeTrue(); actual.CategoryChanges.Should().BeEmpty(); }
public async Task PutEvaluatesProfileConsentTest(ProfileStatus status, bool acceptCoC, bool acceptToS, HttpStatusCode statusCode) { var expected = Model.UsingBuildStrategy <ProfileBuildStrategy>().Create <UpdatableProfile>().Set(x => { x.AcceptCoC = acceptCoC; x.AcceptToS = acceptToS; x.Status = status; }); var user = ClaimsIdentityFactory.Build(null, expected); await Client.Put(ApiLocation.AccountProfile, _logger, expected, user, statusCode) .ConfigureAwait(false); }
void _td_ProfileDefinitionCompleted(IProfileDefinition profile, ProfileStatus status, string dump) { ProfileTestInfo info = new ProfileTestInfo(); info.Status = status; info.Log = dump; if (_profilesSupportInfo.ContainsKey(profile)) { _profilesSupportInfo[profile] = info; } else { _profilesSupportInfo.Add(profile, info); } }
public async Task GetReturnsProfileBasedOnStatusTest(ProfileStatus status, bool found) { var profile = await Model.UsingBuildStrategy <ProfileBuildStrategy>().Create <Profile>().Set(x => x.Status = status).Save() .ConfigureAwait(false); var actual = await Client.Get <List <ProfileResult> >(ApiLocation.Profiles, _logger).ConfigureAwait(false); if (found) { actual.Should().Contain(x => x.Id == profile.Id); } else { actual.Should().NotContain(x => x.Id == profile.Id); } }
/// <summary> /// Initializes a new instance of the UserProfileView class. /// </summary> public UserProfileView(string userHandle, string firstName, string lastName, string bio, string photoHandle, string photoUrl, Visibility visibility, long totalTopics, long totalFollowers, long totalFollowing, FollowerStatus followerStatus, FollowingStatus followingStatus, ProfileStatus profileStatus) { UserHandle = userHandle; FirstName = firstName; LastName = lastName; Bio = bio; PhotoHandle = photoHandle; PhotoUrl = photoUrl; Visibility = visibility; TotalTopics = totalTopics; TotalFollowers = totalFollowers; TotalFollowing = totalFollowing; FollowerStatus = followerStatus; FollowingStatus = followingStatus; ProfileStatus = profileStatus; }
// GET: /Profile/ public ActionResult Index() { var currentUser = UserDB.Users.Find(User.Identity.GetUserId()); if (currentUser.MadeProfileYet) { var vm = new ProfileStatus(); vm.StatusList = new List <Status>(); Guid UserId = new Guid(User.Identity.GetUserId()); var profile = db.UserProfiles.FirstOrDefault(x => x.AspNetUser_Id == UserId); vm.Profile = profile; var listOfAllStatuses = db.Statuses.ToList(); var listOfUserStatus = new List <Status>(); foreach (Status x in listOfAllStatuses) { if (x.UserWhomStatusBelongsTo == profile.Id) { listOfUserStatus.Add(x); } } foreach (var entry in listOfUserStatus) { vm.StatusList.Add(entry); } if (vm.StatusList.Count == 0) { Status firstStatus = new Status(); Profile aProfile = new Profile(); firstStatus.StatusUpdate = "Welcome!"; firstStatus.TimeOfUpdate = DateTime.Now; firstStatus.UserWhomStatusBelongsTo = aProfile.AspNetUser_Id; firstStatus.UpdatedByFullName = aProfile.FullName; db.Statuses.Add(firstStatus); vm.StatusList.Add(firstStatus); db.SaveChanges(); //vm.StatusList.Add(new Status { StatusUpdate = "Welcome!", UserWhomStatusBelongsTo = profile.Id, UpdatedByFullName = profile.FullName, TimeOfUpdate = DateTime.Now }); } return(View(vm)); } else { return(RedirectToAction("CreateProfile")); } }
public async Task GetDoesNotReturnProfileWhenUpdatedToHiddenTest(ProfileStatus status) { var account = Model.Create <Account>(); var profile = await Model.UsingBuildStrategy <ProfileBuildStrategy>().Create <Profile>().Set(x => x.Status = status) .Save(_logger, account).ConfigureAwait(false); var firstActual = await Client.Get <List <ProfileResult> >(ApiLocation.Profiles, _logger) .ConfigureAwait(false); firstActual.Should().Contain(x => x.Id == profile.Id); await profile.Set(x => x.Status = ProfileStatus.Hidden).Save(_logger, account).ConfigureAwait(false); var secondActual = await Client.Get <List <ProfileResult> >(ApiLocation.Profiles, _logger) .ConfigureAwait(false); secondActual.Should().NotContain(x => x.Id == profile.Id); }
public static string Status(ProfileStatus profileStatus) { switch (profileStatus) { case ProfileStatus.AccountCreated: return "0"; case ProfileStatus.Profiled: return "1"; case ProfileStatus.EmailVerified: return "3"; case ProfileStatus.IncorrectEmail: return "5"; case ProfileStatus.AccountDisabled: return "404"; default: return null; } }
// GET: /Profile/ public ActionResult Index() { var currentUser = UserDB.Users.Find(User.Identity.GetUserId()); if (currentUser.MadeProfileYet) { var vm = new ProfileStatus(); vm.StatusList = new List <Status>(); Guid UserId = new Guid(User.Identity.GetUserId()); var profile = db.UserProfiles.FirstOrDefault(x => x.AspNetUser_Id == UserId); vm.Profile = profile; return(View(vm)); } else { return(RedirectToAction("CreateProfile")); } }
//GET public ActionResult ShowFriends(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Profile profile = db.UserProfiles.Find(id); if (profile == null) { return(HttpNotFound()); } var vm = new ProfileStatus(); vm.StatusList = new List <Status>(); vm.ProfileCollection = new List <Profile>(); vm.ProfileCollection = db.UserProfiles.ToList(); vm.ProfileCollection.Remove(profile); vm.StatusList = db.Statuses.ToList(); return(View(vm)); }
private async Task AddOrReplaceLocal(Profile profile, ProfileStatus status) { using (var cached = await _cachedProfiles.LockedProfileData()) { var local = cached.Local.Get(profile); if (local?.Status == ProfileStatus.Created && status == ProfileStatus.Deleted) { cached.Local.Remove(local); return; } var mapped = Map(profile) .WithStatus(status) .WithSyncStatus(ProfileSyncStatus.InProgress) .WithModifiedAt(DateTime.UtcNow); cached.Local.AddOrReplace( mapped.WithStatusMergedFrom(local)); } }
private Profile GetProfileFromReader(MySqlDataReader reader) { Profile result = null; reader.Read(); int id = int.Parse(reader["id"].ToString()); int idProfile = int.Parse(reader["idProfile"].ToString()); string Password = reader["Password"].ToString(); string Name = reader["Name"].ToString(); string Surname = reader["Surname"].ToString(); string Telephone = reader["Telephone"].ToString(); string Address = reader["Address"].ToString(); int profileCategoryId = int.Parse(reader["ProfileCategory"].ToString()); int profileStatusId = int.Parse(reader["ProfileStatus"].ToString()); ProfileStatus profileStatus = DAO.GetProfileStatusTable().GetElement(profileStatusId); ProfileCategory profileCategory = DAO.GetProfileCategoryTable().GetElement(profileCategoryId); result = new Profile(id, idProfile, Password, Name, Surname, Telephone, Address, profileStatus, profileCategory); return(result); }
void pst_ProfileDefinitionCompleted(IProfileDefinition profile, ProfileStatus status, string dump) { switch (status) { case ProfileStatus.Failed: _failedProfiles.Add(profile); break; case ProfileStatus.NotSupported: _unsupportedProfiles.Add(profile); break; case ProfileStatus.Supported: _supportedProfiles.Add(profile); break; } if (ProfileDefinitionCompleted != null) { ProfileDefinitionCompleted(profile, status, dump); } }
public void ValidateEvaluatesConsentTest(ProfileStatus status, bool acceptCoC, bool acceptToS, bool hasErrors) { var sut = new UpdatableProfile { AcceptCoC = acceptCoC, AcceptToS = acceptToS, Status = status }; var context = new ValidationContext(sut); var errors = sut.Validate(context).ToList(); if (hasErrors) { errors.Should().NotBeEmpty(); } else { errors.Should().BeEmpty(); } }