Пример #1
0
        public ActionResult Match(string id, int campus, int thisday, int?page, string kiosk, bool?kioskmode)
        {
            if (!Authenticate())
            {
                return(Content("not authorized"));
            }

            Response.NoCache();
            CurrentDatabase.SetNoLock();
            DbUtil.LogActivity("checkin " + id);

            var matches = CurrentDatabase.CheckinMatch(id).ToList();

            if (!matches.Any())
            {
                return(new FamilyResult(CurrentDatabase, 0, campus, thisday, 0, false)); // not found
            }

            if (matches.Count() == 1)
            {
                return(new FamilyResult(CurrentDatabase, matches.Single().Familyid.Value, campus, thisday, 0, matches[0].Locked ?? false));
            }

            return(new MultipleResult(matches, page));
        }
Пример #2
0
        public ActionResult NumberSearch(string data)
        {
            if (!Auth())
            {
                return(CheckInMessage.createErrorReturn("Authentication failed, please try again", CheckInMessage.API_ERROR_INVALID_CREDENTIALS));
            }

            CheckInMessage      dataIn = CheckInMessage.createFromString(data);
            CheckInNumberSearch cns    = JsonConvert.DeserializeObject <CheckInNumberSearch>(dataIn.data);

            DbUtil.LogActivity("Check-In Number Search: " + cns.search);

            List <CheckinMatch> matches = CurrentDatabase.CheckinMatch(cns.search).ToList();

            CheckInMessage br = new CheckInMessage();

            br.setNoError();

            int tzOffset = CurrentDatabase.Setting("TZOffset", "0").ToInt();

            List <CheckInFamily> families = new List <CheckInFamily>();

            if (matches.Count > 0)
            {
                foreach (CheckinMatch match in matches)
                {
                    if (match.Familyid != null)
                    {
                        CheckInFamily family = new CheckInFamily(match.Familyid.Value, match.Name, match.Locked ?? false, CurrentDatabase, CurrentImageDatabase);

                        List <CheckinFamilyMember> members = (from a in CurrentDatabase.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 (CheckinFamilyMember member in members)
                        {
                            family.addMember(CurrentDatabase, CurrentImageDatabase, member, cns.day, tzOffset);
                        }

                        families.Add(family);

                        br.count++;
                    }
                }

                br.data = SerializeJSON(families, dataIn.version);
            }

            return(br);
        }