public ActionResult Newsletter(CommunicationsContext context) { var employer = _employersQuery.GetEmployer(context.UserId); if (employer == null) { return(HttpNotFound()); } // Other enabled employers in the same organisation. var organisationHierarchy = _organisationsQuery.GetOrganisationHierarchy(employer.Organisation.Id); var employerIds = _recruitersQuery.GetRecruiters(organisationHierarchy); employerIds = _userAccountsQuery.GetEnabledAccountIds(employerIds); var lastLastLastMonth = new MonthRange(DateTime.Now.AddMonths(-3)); var lastLastMonth = new MonthRange(DateTime.Now.AddMonths(-2)); var lastMonth = new MonthRange(DateTime.Now.AddMonths(-1)); var model = CreateModel <NewsletterModel>(context); model.LoginId = _loginCredentialsQuery.GetLoginId(employer.Id); model.Employer = employer; model.SampleSearches = GetCachedSampleSearches(); model.PreviousSearches = GetPreviousSearches(employer, employerIds, lastMonth); model.Ranks = GetRanks(employer.Id, employerIds, lastLastLastMonth, lastLastMonth, lastMonth); return(View(model)); }
public ActionResult Newsletter(CommunicationsContext context) { var member = _membersQuery.GetMember(context.UserId); if (member == null || !member.IsEnabled || !member.IsActivated) { return(HttpNotFound()); } var candidate = _candidatesQuery.GetCandidate(context.UserId); var resume = candidate.ResumeId == null ? null : _resumesQuery.GetResume(candidate.ResumeId.Value); var model = CreateModel <NewsletterModel>(context); model.Member = member; model.Candidate = candidate; model.Resume = resume; var lastMonth = new DateTimeRange(DateTime.Today.AddMonths(-1), DateTime.Today); model.TotalJobAds = _jobAdReportsQuery.GetCreatedJobAds(lastMonth); model.TotalViewed = _employerMemberAccessReportsQuery.GetMemberViewings(context.UserId, lastMonth); model.ProfilePercentComplete = _memberStatusQuery.GetPercentComplete(member, candidate, resume); var execution = _executeJobAdSearchCommand.SearchSuggested(member, null, new Range(0, MaxSuggestedJobCount)); var jobAds = _jobAdsQuery.GetJobAds <JobAd>(execution.Results.JobAdIds).ToDictionary(j => j.Id, j => j); model.SuggestedJobs = (from i in execution.Results.JobAdIds where jobAds.ContainsKey(i) select jobAds[i]).ToList(); return(View(model)); }
public ActionResult Reengagement(CommunicationsContext context) { var member = _membersQuery.GetMember(context.UserId); if (member == null) { return(HttpNotFound()); } var candidate = _candidatesQuery.GetCandidate(context.UserId); var resume = candidate.ResumeId == null ? null : _resumesQuery.GetResume(candidate.ResumeId.Value); var model = CreateModel <ReengagementModel>(context); model.Member = member; model.Candidate = candidate; if (!member.IsActivated) { // Create a new activation if needed. var emailAddress = member.GetBestEmailAddress().Address; var emailVerification = _emailVerificationsQuery.GetEmailVerification(member.Id, emailAddress); if (emailVerification == null) { emailVerification = new EmailVerification { EmailAddress = emailAddress, UserId = member.Id }; _emailVerificationsCommand.CreateEmailVerification(emailVerification); } model.ActivationCode = emailVerification.VerificationCode; } model.ProfilePercentComplete = _memberStatusQuery.GetPercentComplete(member, candidate, resume); var execution = _executeJobAdSearchCommand.SearchSuggested(member, null, new Range(0, MaxSuggestedJobCount)); var jobAds = _jobAdsQuery.GetJobAds <JobAd>(execution.Results.JobAdIds).ToDictionary(j => j.Id, j => j); model.SuggestedJobs = (from i in execution.Results.JobAdIds where jobAds.ContainsKey(i) select jobAds[i]).ToList(); model.JobSearch = GetJobSearchModel(member, candidate); var lastWeek = new DateTimeRange(DateTime.Today.AddDays(-7), DateTime.Today); model.TotalContactsLastWeek = _employerMemberAccessReportsQuery.GetMemberAccesses(lastWeek); var lastMonth = new DateTimeRange(DateTime.Today.AddMonths(-1), DateTime.Today); model.TotalContactsLastMonth = _employerMemberAccessReportsQuery.GetMemberAccesses(lastMonth); model.TotalViewed = _employerMemberAccessReportsQuery.GetMemberViewings(context.UserId, lastMonth); return(View(model)); }
protected TModel CreateModel <TModel>(CommunicationsContext context) where TModel : CommunicationsModel, new() { return(new TModel { Definition = context.Definition, Category = context.Category, ContextId = context.ContextId, UserId = context.UserId, IsPreview = context.IsPreview, }); }
public ActionResult Edm(CommunicationsContext context) { var member = _membersQuery.GetMember(context.UserId); if (member == null) { return(HttpNotFound()); } var model = CreateModel <NewsletterModel>(context); model.Member = member; return(View(model)); }
private async Task ProcessMessagesAsync(Message message, CancellationToken token) { var json = Encoding.UTF8.GetString(message.Body); Console.WriteLine( $"Received message: SequenceNumber:{message.SystemProperties.SequenceNumber} Body:{json}" ); var notification = JObject.Parse(json); Type notificationType = Assembly.Load("Contacts.Messages").GetType(notification["Type"]?.ToString()); using (var context = new CommunicationsContext(this.options)) { handlers[notificationType](json, context); await context.SaveChangesAsync(); } await subscriptionClient.CompleteAsync(message.SystemProperties.LockToken); }
private async Task ProcessMessagesAsync(Message message, CancellationToken token) { //mock long running process Thread.SpinWait(2000); Console.WriteLine( $"Received message: SequenceNumber:{message.SystemProperties.SequenceNumber} Body:{Encoding.UTF8.GetString(message.Body)}" ); var command = JsonConvert.DeserializeObject <SendCommunicationCommand>(Encoding.UTF8.GetString(message.Body)); using (var context = new CommunicationsContext(this.options)) { var handler = new SendCommunicationCommandHandler(context); await handler.Handle(command); } await queueClient.CompleteAsync(message.SystemProperties.LockToken); }
public SendCommunicationCommandHandler(CommunicationsContext context) { this.context = context; }
public ContactCreatedHandler(CommunicationsContext context) { this.context = context; }
public ContactRemovedHandler(CommunicationsContext context) { this.context = context; }
public ActionResult IosLaunch(CommunicationsContext context) { return(View(CreateModel <CommunicationsModel>(context))); }