public ActionResult NumberSearch(string data) { if (!Auth()) return BaseMessage.createErrorReturn("Authentication failed, please try again", BaseMessage.API_ERROR_INVALID_CREDENTIALS); BaseMessage dataIn = BaseMessage.createFromString(data); CheckInNumberSearch cns = JsonConvert.DeserializeObject<CheckInNumberSearch>(dataIn.data); DbUtil.LogActivity("Check-In Number Search: " + cns.search); var matches = DbUtil.Db.CheckinMatch(cns.search).ToList(); BaseMessage br = new BaseMessage(); br.setNoError(); int tzOffset = DbUtil.Db.Setting("TZOffset", "0").ToInt(); List<CheckInFamily> families = new List<CheckInFamily>(); if (matches.Count > 0) { foreach (var match in matches) { CheckInFamily family = new CheckInFamily(match.Familyid.Value, match.Name, match.Locked ?? false); var members = (from a in DbUtil.Db.CheckinFamilyMembers(match.Familyid, cns.campus, cns.day).ToList() orderby a.Position, a.Position == 10 ? a.Genderid : 10, a.Age descending, a.Hour select a).ToList(); foreach (var member in members) { family.addMember(member, cns.day, tzOffset); } families.Add(family); br.count++; } br.data = SerializeJSON(families, dataIn.version); } return br; }
public ActionResult Search() //string id, int campus, int day { //if (!Auth()) // return BaseMessage.createErrorReturn("Authentication failed, please try again", BaseMessage.API_ERROR_INVALID_CREDENTIALS); //DbUtil.LogActivity("Check-In Search: " + id); /* Replacement for CheckinMatch without the lock SELECT FamilyId, PeopleId, Name, GenderId FROM dbo.People WHERE FamilyId IN (SELECT FamilyId FROM dbo.Families WHERE HomePhoneLU LIKE '4813443%') OR FamilyId IN (SELECT FamilyId FROM dbo.People WHERE CellPhoneLU LIKE '4813443%' OR WorkPhoneLU LIKE '4813443%') AND (CampusId = 1 OR CampusId IS NULL) ORDER BY PositionInFamilyId, GenderId */ //var matches = DbUtil.Db.CheckinMatch(id).ToList(); //if (!matches.Any()) // return new FamilyResult(0, campus, day, 0, false); // not found //if (matches.Count() == 1) // return new FamilyResult(matches.Single().Familyid.Value, campus, day, 0, matches[0].Locked ?? false); //return new MultipleResult(matches, 1); var results = (from p in DbUtil.Db.People where (from f in DbUtil.Db.Families where f.HomePhoneLU.Contains("4813443") select f.FamilyId).Contains(p.FamilyId) || (from o in DbUtil.Db.People where o.CellPhone.Contains("4813443") || o.WorkPhoneLU.Contains("4813443") select o.FamilyId).Contains(p.FamilyId) where p.DeceasedDate == null orderby p.Name select new { p.FamilyId }).Distinct(); var br = new BaseMessage(); var families = new List<CheckInFamily>(); CheckInFamily family; foreach (var item in results) { var members = (from a in DbUtil.Db.CheckinFamilyMembers(item.FamilyId, 1, 1).ToList() orderby a.Position, a.Genderid, a.Age select a).ToList(); if (members.Count() > 0) { family = new CheckInFamily(); family.id = item.FamilyId; family.name = members[0].Name; foreach (var member in members) { family.addMember(new CheckInPerson(member)); } families.Add(family); } } br.error = 0; br.count = results.Count(); br.data = JsonConvert.SerializeObject(families); return br; }
public ActionResult Family(string data) { if (!Auth()) return BaseMessage.createErrorReturn("Authentication failed, please try again", BaseMessage.API_ERROR_INVALID_CREDENTIALS); BaseMessage dataIn = BaseMessage.createFromString(data); CheckInFamilySearch cfs = JsonConvert.DeserializeObject<CheckInFamilySearch>(dataIn.data); DbUtil.LogActivity("Check-In Family: " + cfs.familyID); BaseMessage br = new BaseMessage(); br.setNoError(); int tzOffset = DbUtil.Db.Setting("TZOffset", "0").ToInt(); List<CheckInFamily> families = new List<CheckInFamily>(); FamilyCheckinLock familyLock = DbUtil.Db.FamilyCheckinLocks.SingleOrDefault(f => f.FamilyId == dataIn.argInt); CheckInFamily family = new CheckInFamily(cfs.familyID, "", familyLock == null ? false : familyLock.Locked); var members = (from a in DbUtil.Db.CheckinFamilyMembers(cfs.familyID, cfs.campus, cfs.day).ToList() orderby a.Position, a.Position == 10 ? a.Genderid : 10, a.Age descending, a.Hour select a).ToList(); foreach (var member in members) { family.addMember(member, cfs.day, tzOffset); } families.Add(family); br.count = 1; br.data = SerializeJSON(families, dataIn.version); return br; }