コード例 #1
0
        // POST: Reception/CheckIn/1
        public ActionResult CheckIn(int?id, [Bind(Include = "Id,SocialGathering,IsMinors,IsStudent")] Participant participant, int?studyMeetingId)
        {
            var part = db.Participants.Find(id);

            part.SocialGathering = participant.SocialGathering;
            part.IsMinors        = participant.IsMinors;
            part.IsStudent       = participant.IsStudent;
            part.CheckedIn       = true;
            db.Entry(part).State = EntityState.Modified;

            var hist = new CheckInHistory
            {
                Participant = part
            };

            db.CheckinHistories.Add(hist);

            db.SaveChanges();

            // SignalRで通知
            var context = GlobalHost.ConnectionManager.GetHubContext <CheckInNotifyHub>();

            context.Clients.All.ReceiveMessage();

            return(RedirectToAction("List", new { id = studyMeetingId }));
        }
コード例 #2
0
        private async void SearchButtonPressed(object sender, RoutedEventArgs e)
        {
            bool clientFound = false;

            CheckInSearchButton.IsEnabled = false;
            if (CheckInButton.IsEnabled)
            {
                ResetContent();
                await Task.Delay(500);
            }
            ((Storyboard)InputBorder.Resources["LoadingAnimation"]).Begin();
            if (!int.TryParse(CheckInSearchText.Text, out int n) || n < 0)
            {
                MessageBox.Show("Invalid phone number");
                ((Storyboard)InputBorder.Resources["LoadingAnimation"]).Stop();
                ((Storyboard)InputBorder.Resources["EndingAnimation"]).Begin();
                CheckInSearchButton.IsEnabled = true;
                return;
            }
            string Phonenumber  = CheckInSearchText.Text;
            Client client       = null;
            bool   HasCheckedIn = false;
            await Task.Run(() =>
            {
                client = Galaxi.GetClient(Phonenumber);
            });

            if (client == null)
            {
                MessageBox.Show("Client does not exist");
            }
            else
            {
                clientFound = true;
                CheckInHistory lastCheckIn = null;
                await Task.Run(() =>
                {
                    lastCheckIn = Galaxi.GetLastCheckin(client);
                });

                if (lastCheckIn == null)
                {
                    HasCheckedIn = false;
                }
                else
                {
                    HasCheckedIn = !lastCheckIn.IsCheckedOut;
                }
                CheckInClientName.Content  = client.Name;
                CheckInClienYear.Content   = client.Year.ToString();
                CheckInEmail.Content       = client.Email;
                CheckInFacultyName.Content = client.Faculty.Name;
                CheckInStatus.Content      = HasCheckedIn ? $"Checked-In at {lastCheckIn.CheckIn.ToShortTimeString()}" : "Not Checked-In";
            }
            CheckInSearchButton.IsEnabled = true;
            if (clientFound)
            {
                CheckInButton.IsEnabled = true;
            }
            else
            {
                CheckInButton.IsEnabled = false;
            }
            ((Storyboard)InputBorder.Resources["LoadingAnimation"]).Stop();
            ((Storyboard)InputBorder.Resources["EndingAnimation"]).Begin();
            if (!HasCheckedIn)
            {
                CheckInButton.Content = "Check in!";
                ((Storyboard)CheckInOutPanel.Resources["CheckInEnabled"]).Begin();
            }
            else
            {
                CheckInButton.Content = "Check out!";
                ((Storyboard)CheckInOutPanel.Resources["CheckOutEnabled"]).Begin();
            }
            CurrentActiveClient = client;
        }