Ejemplo n.º 1
0
        public Residency AddResidency(Organization organization)
        {
            var residency = new Residency {
                Client = this, OrganizationId = organization.Id, Organization = organization
            };

            Residencies.Add(residency);
            return(residency);
        }
Ejemplo n.º 2
0
 private void UpdateLivingUnit(Residency residency, ApplicationDbContext context)
 {
     if (this.LivingUnitId.HasValue)
     {
         var livingUnit = context.LivingUnits.FirstOrDefault(l => l.Id == this.LivingUnitId);
         residency.LivingUnit = livingUnit;
     }
     else
     {
         residency.LivingUnitId = new int?();
         residency.LivingUnit   = null;
     }
 }
Ejemplo n.º 3
0
        private void UpdateGuardians(Residency residency, ApplicationDbContext context)
        {
            //remove deleted guardians
            var idsToRemove = this.Guardians.Where(a => a.Add != true).Select(a => a.Id);

            residency.Guardians.Where(a => !idsToRemove.Contains(a.Id))
            .ToArray()
            .ForEach(a =>
            {
                residency.Guardians.Remove(a);
            });

            //add new attorneys
            var idsToAdd = this.Guardians.Where(a => a.Add).Select(a => a.Id);

            context.Payees.Where(p => idsToAdd.Contains(p.Id))
            .ForEach(p =>
            {
                residency.Guardians.Add(p);
            });
        }
Ejemplo n.º 4
0
 public void UpdateResidency(Residency residency, ApplicationDbContext context)
 {
     UpdateLivingUnit(residency, context);
     UpdateAttorneys(residency, context);
     UpdateGuardians(residency, context);
 }