} // Create public ProjectOrganisation Update(Organisation org) { ProjectOrganisationData pod = POD(org.Id); pod.Details.CopyFrom(org.organisation()); Commit(pod); return Get(pod.Details.Id); } // Update
} // DeleteLocations public IList<Location> FetchLocations(Guid orgId) { ProjectOrganisationData pod = POD(orgId); if (pod.Locations != null) return pod.Locations.Select(l => new Location(l)).OrderBy(loc => loc.Name).ToList(); return new List<Location>(); } // FetchLocations
} // DeleteReferralAgency public IList<ReferralAgency> FetchReferralAgencies(Guid orgId) { ProjectOrganisationData pod = POD(orgId); if (pod.ReferralAgencies != null) return pod.ReferralAgencies.Select(rad => new ReferralAgency(rad)).OrderBy(rad => rad.Name).ToList(); return new List<ReferralAgency>(); } // FetchReferralAgency
public OrganisationClients(Guid orgId, DbSet<ClientData> clients) { ProjectOrganisationData pod = ProjectOrganisationRepository.findOrg(orgId); locations_ = pod.Locations.Select(loc => loc.Id).ToArray(); index_ = 0; clients_ = clients; enumerator_ = nextEnumerator(); } // OrganisationClients
} // DeleteStaffMember public IList<StaffMember> FetchStaffMembers(Guid orgId) { ProjectOrganisationData pod = POD(orgId); if (pod.Staff != null) { using (var authRepo = new AuthRepository()) { return pod.Staff.Select(sm => new StaffMember(sm, authRepo.UserRoles(sm.UserName))).OrderBy(sm => sm.Name).ToList(); } } // if ... return new List<StaffMember>(); } // FetchStaffMembers
} // AddProjectQuestion public IList<Project> FetchProjects(Guid orgId) { ProjectOrganisationData pod = POD(orgId); var projects = new List<Project>(); if (pod.Projects != null) foreach (var proj in pod.Projects) projects.Add(new Project(proj)); return projects.OrderBy(p => p.Name).ToList(); } // FetchProjects
} // AllOrganisations public ProjectOrganisation Create(Organisation org) { ProjectOrganisationData pod = new ProjectOrganisationData(); pod.Application = ApplicationName; pod.Details = org.organisation(); pod.Id = Guid.NewGuid(); pod.Details.Id = Guid.NewGuid(); pod.Details.Address.Id = Guid.NewGuid(); context.ProjectOrganisations.Add(pod); Commit(); return Get(pod.Details.Id); } // Create
} // POD private ProjectOrganisationData POD(Expression<Func<ProjectOrganisationData, bool>> where) { ProjectOrganisationData pod = context.ProjectOrganisations. Where(p => p.Application == ApplicationName). Where(where). Include(p => p.Details). Include(p => p.Details.Address). Include(p => p.Projects). Include(p => p.Projects.Select(pj => pj.Address)). Include(p => p.Projects.Select(pj => pj.Questions)). Include(p => p.Locations). Include(p => p.Locations.Select(loc => loc.Address)). Include(p => p.ReferralAgencies). Include(p => p.ReferralAgencies.Select(ra => ra.Address)). Include(p => p.Staff). SingleOrDefault(); if (pod != null && pod.Projects != null) pod.Projects.Sort(ProjectCompareByName); return pod; } // POD