Esempio n. 1
0
 private void AddMissingJoinedOnDates(IIncludableQueryable <Member, ICollection <Change> > members, ILogger log)
 {
     this.ChangeTracker.AutoDetectChangesEnabled = false;
     foreach (var m in members.ToArray().Where(x => x.JoinedOn == null && !x.HasLeft && x.Payments.Count() > 0).ToArray())
     {
         var ep = m.Payments.OrderBy(x => x.DueDate).FirstOrDefault().DueDate;
         if (ep != null)
         {
             m.JoinedOn = ep;
             var cr = new Change
             {
                 Date        = DateTimeOffset.Now,
                 MadeBy      = "System",
                 Member      = m,
                 Description = $"Joined on date {ep.ToDefault()} taken from payment record"
             };
             m.Changes.Add(cr);
             //this.SaveChanges();
             log.Information($"set member {m.Name} joining date to {ep.ToDefault()}");
         }
     }
     this.ChangeTracker.DetectChanges();
     this.SaveChanges();
     this.ChangeTracker.AutoDetectChangesEnabled = true;
 }
Esempio n. 2
0
 private void SplitMultipleMemberships(IIncludableQueryable <Member, ICollection <Change> > members, ILogger log)
 {
     foreach (var m in members.ToArray().Where(x => x.MemberCount > 1 && !x.HasLeft).ToArray())
     {
         var(fn1, ln1, fn2, ln2) = Splitnames(m);
         var email1 = "none";
         var email2 = "none";
         if (!string.IsNullOrWhiteSpace(m.Email))
         {
             m.Email          = m.Email.Replace("\n", " ");
             (email1, email2) = SplitEmails(m);
         }
         log.Trace($"split \"{m.Name} ({m.Email})\" into \"{fn1} {ln1} ({email1})\" and \"{fn2} {ln2} ({email2})\"");
     }
 }