public void ImportAgeRanges(ArrayList rows) { int length = rows.Count; for (int i = 0; i < length; i++) { Dictionary <string, int> row = rows[i] as Dictionary <string, int>; string title; int startAge = row["start age"]; int endAge = row["end age"]; if (startAge == 0) { title = string.Format("under {0}", endAge); } else if (endAge >= 99) { title = string.Format("{0}+", startAge); } else if (startAge + 1 == endAge) { title = string.Format("{0}, {1}", startAge, endAge); } else { title = string.Format("{0} to {1}", startAge, endAge); } NAgeRange ageRange = new NAgeRange(i, title, startAge, endAge); AgeRanges.Add(ageRange); } }
/// <summary> /// Generates a random age /// </summary> /// <param name="types">Age range.</param> /// <returns>Returns random generated age.</returns> public int NextAge(AgeRanges types = AgeRanges.Adult) { int[] range; switch (types) { case AgeRanges.Child: range = new[] { 1, 12 }; break; case AgeRanges.Teen: range = new[] { 13, 19 }; break; case AgeRanges.Senior: range = new[] { 65, 100 }; break; case AgeRanges.All: range = new[] { 1, 100 }; break; default: range = new[] { 18, 65 }; break; } return(NextNatural(range[0], range[1])); }
public ActionResult <IEnumerable <string> > GetAges() { var ages = AgeRanges.GetAgeRanges().Select(x => x.range).ToList();; if (ages.Count > 0) { return(ages); } return(BadRequest("No Ages Found")); }
internal Person(Chance chance, AgeRanges ageRange = AgeRanges.Any, Gender?gender = null, string emailDomain = null) { Gender = gender ?? chance.Gender(); NamePrefix = chance.NamePrefix(Gender); FirstName = chance.FirstName(Gender); MiddleName = chance.FirstName(Gender); LastName = chance.LastName(); NameSuffix = chance.NameSuffix(); SSN = chance.SSN(); Birthday = chance.Birthday(ageRange); Phone = chance.Phone(); Email = chance.Email(domain: emailDomain); }
private List <Combination> CalculateCombinationAgeAnalytics(List <FirstAid> fas, int param) { var f = fas.OrderByDescending(x => x.age).ToList(); var ageranges = AgeRanges.GetAgeRanges(); foreach (var el in f) { AgeRange ar = null; int year = DateTime.Now.Year; if (int.TryParse(el.age, out int a)) { ar = ageranges.FirstOrDefault(x => year - x.startyear < a && year - x.endYear >= a); el.age = ar.range; } } return(CalculateCombinationAnalytics(f, param)); }
public BirthdayAttribute(AgeRanges range = (AgeRanges) ~0) { this.range = range; }
private List <FirstAid> ExecuteFilter(IQueryable <FirstAid> fas, Filter f) { var query = fas; //Execute Filters if (!string.IsNullOrEmpty(f.gender)) { query = query.Where(x => x.gender != null && x.gender.Equals(f.gender)); } if (!string.IsNullOrEmpty(f.age)) { var ageRange = AgeRanges.GetAgeRanges().FirstOrDefault(x => x.range.Equals(f.age)); int start = DateTime.Now.Year - ageRange.startyear; int end = DateTime.Now.Year - ageRange.endYear; List <string> years = new List <string>(); for (int i = start + 1; i <= end; i++) { years.Add(i.ToString()); } query = query.Where(x => x.age != null && years.Contains(x.age)); } if (!string.IsNullOrEmpty(f.country)) { query = query.Where(x => x.country != null && x.country.Equals(f.country)); } if (f.from.HasValue) { query = query.Where(x => x.assignDate != null && x.assignDate >= (DateTime)f.from); } if (f.to.HasValue) { query = query.Where(x => x.assignDate != null && x.assignDate <= (DateTime)f.to); } if (!string.IsNullOrEmpty(f.education)) { query = query.Where(x => x.education != null && x.education.Equals(f.education)); } if (!string.IsNullOrEmpty(f.assistance)) { var assistanceId = _context.Assistance.FirstOrDefault(x => x.name.Equals(f.assistance)).id; var ids = _context.FAAssistance.Where(x => x.AId == assistanceId).Select(x => x.FAId).ToList(); query = query.Where(x => x.id != null && ids.Contains((int)x.id)); } if (!string.IsNullOrEmpty(f.injury)) { var injuryId = _context.Injury.FirstOrDefault(x => x.name.Equals(f.injury)).id; var ids = _context.FAInjury.Where(x => x.IId == injuryId).Select(x => x.FAId).ToList(); query = query.Where(x => x.id != null && ids.Contains((int)x.id)); } if (!string.IsNullOrEmpty(f.typeOfFA)) { switch (f.typeOfFA) { case "Red Cross FA Training(s)": query = query.Where(x => (x.trainingByRC == null) ? false : (bool)x.trainingByRC); break; case "Other FA Training(s)": query = query.Where(x => (x.hadFATraining == null) ? false : ((bool)x.hadFATraining && x.otherTrainingProvider != null)); break; case "Red Cross & Other FA Trainings": query = query.Where(x => (x.hadFATraining == null || x.trainingByRC == null) ? false : ((bool)x.trainingByRC && x.otherTrainingProvider != null)); break; case "None": query = query.Where(x => (x.hadFATraining == null) ? true : !(bool)x.hadFATraining); break; default: break; } } return(query.ToList()); }
public AgeAttribute(AgeRanges range = (AgeRanges) ~0) { this.range = range; }
private void OnDelete() { AgeRanges.Remove(SelectedAgeRange); }
public PersonAttribute(AgeRanges ageRange = (AgeRanges) ~0, Gender gender = (Gender) ~0, String emailDomain = null) { this.ageRange = ageRange; this.gender = gender; this.emailDomain = emailDomain; }