public ProposalMemoryService(IDataProtectionProvider dataProtProvider, PurposeKeys purposeKeys) { _dataProtector = dataProtProvider.CreateProtector(purposeKeys.ProposalIdKey); proposals.Add(new ProposalModel { Id = 1, EncryptedId = _dataProtector.Protect("1"), ConferenceId = 1, Speaker = "Roland Guijt", Title = "Understanding ASP.NET Core Security" }); proposals.Add(new ProposalModel { Id = 2, EncryptedId = _dataProtector.Protect("2"), ConferenceId = 2, Speaker = "John Reynolds", Title = "Starting Your Developer Career" }); proposals.Add(new ProposalModel { Id = 3, EncryptedId = _dataProtector.Protect("3"), ConferenceId = 2, Speaker = "Stan Lipens", Title = "ASP.NET Core TagHelpers" }); }
/// <summary> /// Gets the existing relationship. /// </summary> /// <param name="rockContext">The rock context.</param> /// <param name="relatedEntityService">The related entity service.</param> /// <returns></returns> private List <RelatedEntity> GetExistingRelationships() { var rockContext = new RockContext(); var relatedEntityService = new RelatedEntityService(rockContext); // Get entity type for person alias. If either the source or target use person alias // we'll want to search using any of the aliases for the person var personAliasEntityId = EntityTypeCache.Get(Rock.SystemGuid.EntityType.PERSON_ALIAS).Id; var personAliasService = new PersonAliasService(rockContext); var personAliasSourceQry = GetAllPersonAliasesForPersonByPersonAlias(sourceEntityId.Value, personAliasService); var qry = relatedEntityService.Queryable() .Where(r => r.SourceEntityTypeId == sourceEntityTypeId && r.TargetEntityTypeId == targetEntityTypeId && PurposeKeys.Contains(r.PurposeKey) ); // Add filters for EntityIds if (sourceEntityTypeId == personAliasEntityId) { qry = qry.Where(r => personAliasSourceQry.Contains(r.SourceEntityId)); } else { qry = qry.Where(r => r.SourceEntityId == sourceEntityId); } // Return results var results = qry.ToList(); return(results); }
/// <summary> /// Processes the add request. /// </summary> /// <param name="parms">The parms.</param> private void ProcessAddRequest(List <string> parms) { var confirmationMessage = string.Empty; var purposeKey = PurposeKeys.First() ?? string.Empty; Guid sourceEntityGuid; Guid targetEntityGuid; // Get source entity id if (Guid.TryParse(parms[0], out sourceEntityGuid)) { var sourceEntityId = Reflection.GetEntityIdForEntityType(sourceEntityTypeId, sourceEntityGuid); this.CurrentSourceEntityId = sourceEntityId.HasValue ? sourceEntityId.Value : 0; } else { this.CurrentSourceEntityId = parms[0].AsInteger(); } // Get target entity id if (Guid.TryParse(parms[1], out targetEntityGuid)) { var targetEntityId = Reflection.GetEntityIdForEntityType(targetEntityTypeId, targetEntityGuid); this.CurrentTargetEntityId = targetEntityId.HasValue ? targetEntityId.Value : 0; } else { this.CurrentTargetEntityId = parms[1].AsInteger(); } // Check that we have valid entity ids if (this.CurrentSourceEntityId == 0 || this.CurrentTargetEntityId == 0) { return; } // Get purpose key if (parms.Count >= 3) { this.CurrentPurposeKey = parms[2]; } // Get confirmation message if (parms.Count >= 4) { confirmationMessage = parms[3]; } // If no add confirmation requested just add the item if (confirmationMessage.IsNullOrWhiteSpace()) { AddRelationship(); return; } // Show confirmation message lConfirmAddMsg.Text = HttpUtility.UrlDecode(confirmationMessage); mdConfirmAdd.Show(); }
public ConferenceMemoryService(IDataProtectionProvider dataProtProvider, PurposeKeys purposeKeys) { _dataProtector = dataProtProvider.CreateProtector(purposeKeys.ConferenceIdKey); conferences.Add(new ConferenceModel { Id = 1, Name = "NDC", EncryptedId = _dataProtector.Protect("1"), Location = "Oslo", Start = new DateTime(2017, 6, 12), AttendeeTotal = 2132 }); conferences.Add(new ConferenceModel { Id = 2, Name = "IT/DevConnections", EncryptedId = _dataProtector.Protect("2"), Location = "San Francisco", Start = new DateTime(2017, 10, 18), AttendeeTotal = 3210 }); }
/// <summary> /// Displays the delete relationship. /// </summary> /// <param name="relationshipId">The relationship identifier.</param> private void ProcessDeleteRequest(List <string> parms) { var confirmationMessage = string.Empty; var purposeKey = PurposeKeys.First() ?? string.Empty; Guid relationshipGuid; if (!Guid.TryParse(parms[0], out relationshipGuid)) { return; // Invalid related entity guid provided } // Get purpose key if (parms.Count >= 2) { purposeKey = parms[1]; } // Get confirmation message if (parms.Count >= 3) { confirmationMessage = parms[2]; } var rockContext = new RockContext(); var relatedEntityService = new RelatedEntityService(rockContext); var relatedEntity = relatedEntityService.Get(relationshipGuid); if (relatedEntity != null) { // Persist the relationship id for use in partial postbacks this.CurrentRelationshipId = relatedEntity.Id; this.CurrentPurposeKey = purposeKey; // If no confirmation message process delete now. if (confirmationMessage.IsNullOrWhiteSpace()) { DeleteExistingRelationship(); return; } else { lConfirmDeleteMsg.Text = HttpUtility.UrlDecode(confirmationMessage); } mdConfirmDelete.Show(); } }
public ProposalController(IConferenceService conferenceService, IProposalService proposalService, IDataProtectionProvider dataProtProvider, PurposeKeys purposeKeys) { _dataProtector = dataProtProvider.CreateProtector(purposeKeys.ConferenceIdKey); this.conferenceService = conferenceService; this.proposalService = proposalService; }