public void OnGet(int JobLeadId, string TemplateName) { Template = _docProvider.GetTemplateDocs().Where(t => t.Name == TemplateName).SingleOrDefault(); JobLead JobLead = _jobLeadService.GetById(JobLeadId); Template.Content = _jobLeadService.CompileTemplate(Template.Content, JobLead); }
public IActionResult OnGet(int?id) { JobLead = new JobLead() { JobLeadId = 0 , Password = Utils.GeneratePassword(16) }; if (id != null && id > 0) { JobLead = _jobLeadService.GetAll() .Where(o => o.JobLeadId == id.GetValueOrDefault()) .SingleOrDefault(); } Templates = new List <Template>(); foreach (Template template in _docProvider.GetTemplateDocs()) { template.Content = _jobLeadService.CompileTemplate(template.Content, JobLead); Templates.Add(template); } selectList = new SelectList(Templates.ToList(), nameof(Template.Name), nameof(Template.Name)); SelectedItems = new string[] { "resume.html", "cover.html" }; return(Page()); }
private void CreateJobLead(Guid jobListingId, JobInfo jobInfo) { var newLead = new JobLead(jobListingId, jobInfo); newLead.DisplayOrder = leadManager.GetNumberOfJobLeads; leadManager.AddJobLead(newLead); }
public virtual void Delete(JobLead instance) { if (instance == null) { throw new ArgumentNullException(this.ToString()); } _repository.Delete(instance); }
private void Delete_Button_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Delete Job Lead?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { leadManager.RemoveJobLead(selectedJobLead); selectedJobLead = null; } }
public virtual JobLead GetById(int id) { JobLead instance = _repository.GetById(id); if (instance.Password != null) { instance.Password = _encryptionService.Decrypt(instance.Password, instance.PasswordSalt); } return(instance); }
public void RemoveJobLead(JobLead existingJobLead) { if (jobLeads.Contains(existingJobLead)) { jobLeads.Remove(existingJobLead); uiCallback(jobLeads); SaveJobLeads(); } else { // add logging and/or throw exception here... } }
public virtual string CompileTemplate(string TemplateContent, JobLead item) { var props = typeof(JobLead).GetProperties(); foreach (var prop in props) { string val = prop.GetValue(item) == null ? "" : prop.GetValue(item).ToString(); TemplateContent = TemplateContent.Replace( string.Format("#{0}#", prop.Name.ToString()), val ); } return(TemplateContent); }
public virtual void Update(JobLead instance) { if (instance == null) { throw new ArgumentNullException(this.ToString()); } instance.PasswordSalt = DbUtil.GetSaltById(instance.JobLeadId); if (instance.Password != null) { instance.Password = _encryptionService.Encrypt(instance.Password, instance.PasswordSalt); } _repository.Update(instance); }
public virtual void Insert(JobLead instance) { if (instance == null) { throw new ArgumentNullException(this.ToString()); } instance.PasswordSalt = _encryptionService.CreateSalt(24); if (instance.Password != null) { instance.Password = _encryptionService.Encrypt(instance.Password, instance.PasswordSalt); } _repository.Insert(instance); }
public void DecreaseJobLeadDisplayOrder(JobLead leadToDecrease) { var sortedLeads = jobLeads.OrderBy(lead => lead.DisplayOrder).ToArray(); for (int i = 0; i < sortedLeads.Length; i++) { var leadAtIndex = sortedLeads[i]; if (leadAtIndex == leadToDecrease && i > 0) { var leadToIncrease = sortedLeads[i - 1]; leadToDecrease.DisplayOrder--; leadToIncrease.DisplayOrder++; SaveJobLeads(); uiCallback(jobLeads); } } }
private void JobLeads_ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (JobLeads_ListBox.SelectedItem != null) { var listBoxItem = (ListBoxItem)JobLeads_ListBox.SelectedItem; selectedJobLead = (JobLead)listBoxItem.Content; Edit_Button.IsEnabled = true; Delete_Button.IsEnabled = true; IncreaseDisplayOrder_Button.IsEnabled = JobLeads_ListBox.SelectedIndex < JobLeads_ListBox.Items.Count - 1; DecreaseDisplayOrder_Button.IsEnabled = JobLeads_ListBox.SelectedIndex > 0; } else { Edit_Button.IsEnabled = false; Delete_Button.IsEnabled = false; IncreaseDisplayOrder_Button.IsEnabled = false; DecreaseDisplayOrder_Button.IsEnabled = false; } }
private void UpdateDisplayList(IEnumerable <JobLead> leads) { JobLeads_ListBox.Items.Clear(); Edit_Button.IsEnabled = false; Delete_Button.IsEnabled = false; selectedJobLead = null; var leadsList = leads .ToList() .OrderBy(lead => lead.DisplayOrder); foreach (var lead in leadsList) { var listBoxItem = new ListBoxItem { Content = lead, FontWeight = lead.JobInfo.IsFavorite ? FontWeights.Bold : FontWeights.Normal, Foreground = lead.JobInfo.IsFavorite ? Brushes.DarkGoldenrod : Brushes.Black, }; JobLeads_ListBox.Items.Add(listBoxItem); } }
public void AddJobLead(JobLead newJobLead) { jobLeads.Add(newJobLead); uiCallback(jobLeads); SaveJobLeads(); }