Ejemplo n.º 1
0
        public UnitApplicant[] GetApplicants(Guid id)
        {
            if (!Permissions.IsUser)
            {
                ThrowAuthError();
            }

            Guid rootOrgId = Guid.Empty;

            Guid.TryParse(ConfigurationManager.AppSettings["rootOrgId"], out rootOrgId);

            var query = db.UnitApplicants.Include("Applicant.ContactNumbers", "Applicant.EmergencyContacts");

            if (id != rootOrgId)
            {
                query = query.Where(f => f.Unit.Id == id);
            }

            MembersController members = new MembersController(this.db, this.log);

            var notDoneDocs = new[] { Model.DocumentStatus.NotApplicable.ToString(), Model.DocumentStatus.NotStarted.ToString() };

            return(query.OrderBy(f => f.Applicant.LastName).ThenBy(f => f.Applicant.FirstName).AsEnumerable().Select(f =>
            {
                var docs = members.GetUnitDocuments(f.Applicant.Id);

                return new UnitApplicant
                {
                    Id = f.Id,
                    MemberId = f.Applicant.Id,
                    NameReverse = f.Applicant.ReverseName,
                    Email = f.Applicant.ContactNumbers.Where(g => g.Type == "email").OrderBy(g => g.Priority).Select(g => g.Value).FirstOrDefault(),
                    EmergencyContactCount = f.Applicant.EmergencyContacts.Count,
                    Background = f.Applicant.BackgroundText,
                    Username = f.Applicant.Username,
                    Started = f.Started,
                    Active = f.IsActive,
                    RemainingDocCount = docs.Count() - docs.Count(g => !notDoneDocs.Contains(g.Status))
                };
            }).ToArray());
        }
Ejemplo n.º 2
0
        public UnitApplicant[] GetApplicants(Guid id)
        {
            if (!Permissions.IsUser) ThrowAuthError();

              Guid rootOrgId = Guid.Empty;
              Guid.TryParse(ConfigurationManager.AppSettings["rootOrgId"], out rootOrgId);

              var query = db.UnitApplicants.Include("Applicant.ContactNumbers", "Applicant.EmergencyContacts");
              if (id != rootOrgId)
              {
            query = query.Where(f => f.Unit.Id == id);
              }

              MembersController members = new MembersController(this.db, this.log);

              var notDoneDocs = new[] { Model.DocumentStatus.NotApplicable.ToString(), Model.DocumentStatus.NotStarted.ToString() };

              return query.OrderBy(f => f.Applicant.LastName).ThenBy(f => f.Applicant.FirstName).AsEnumerable().Select(f =>
              {
            var docs = members.GetUnitDocuments(f.Applicant.Id);

            return new UnitApplicant
            {
              Id = f.Id,
              MemberId = f.Applicant.Id,
              NameReverse = f.Applicant.ReverseName,
              Email = f.Applicant.ContactNumbers.Where(g => g.Type == "email").OrderBy(g => g.Priority).Select(g => g.Value).FirstOrDefault(),
              EmergencyContactCount = f.Applicant.EmergencyContacts.Count,
              Background = f.Applicant.BackgroundText,
              Username = f.Applicant.Username,
              Started = f.Started,
              Active = f.IsActive,
              RemainingDocCount = docs.Count() - docs.Count(g => !notDoneDocs.Contains(g.Status))
            };
              }).ToArray();
        }