예제 #1
0
 public ScheduledVisitsViewModel(IEnumerable <Visitor> results)
 {
     if (results == null)
     {
         api = new K12RestApi();
     }
 }
예제 #2
0
        public BehaviorProfileViewModel(string studentId, string behaviorReason)
        {
            BehaviorReason = behaviorReason;

            api = new K12RestApi();
            Init(studentId);
        }
예제 #3
0
        public async void ExecuteNavigation()
        {
            try
            {
                K12RestApi api       = new K12RestApi();
                var        companies = await api.GetCompanies();

                if (companies.Count() < 1 || companies == null)
                {
                    throw new Exception("Could not find any buildings associated with login.");
                }
                var selection = await DisplayActionSheet("Select building", null, null, (from x in companies select x.Name).ToArray());

                var selectedCompany = (from x in companies
                                       where x.Name == selection
                                       select x).FirstOrDefault();

                api.SetCurrentCompany(selectedCompany);

                var d = new DashboardView();

                await this.Navigation.PushAsync(d, true);

                this.Navigation.RemovePage(this);
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error!", ex.Message, "OK");
            }
            finally
            {
                lvm.IsBusy = false;
            }
        }
예제 #4
0
 public CurrentEventsViewModel(IEnumerable <EventRecord> results)
 {
     if (results == null)
     {
         api = new K12RestApi();
     }
 }
 public CurrentVisitorsViewModel(IEnumerable <Visitor> results)
 {
     if (results == null)
     {
         api = new K12RestApi();
     }
 }
예제 #6
0
        public StudentProfileViewModel(StudentDetails details)
        {
            api          = new K12RestApi(); // what's this, precious?
            this.Details = details;

            Init();
        }
예제 #7
0
        public SearchView()
        {
            InitializeComponent();
            api = new K12RestApi();

            BindingContext = vm = new SearchViewModel();
            vm.Nav         = this;
            this.txtSearch.Focus();
        }
예제 #8
0
        async void InitFromScanCode(string scancode)
        {
            try
            {
                api = new K12RestApi();
                var res = await this.GetStudent(scancode);

                if (res)
                {
                    Init();
                }
            }
            catch (Exception ex)
            {
                Nav.ShowAlert("Error", "Could not retrieve Student info from server");
            }
        }
        async void Init(StudentDetails details)
        {
            try
            {
                api          = this.GetApiInstance();
                this.Details = details;
                IsBusy       = true;


                this.LatestLog = await GetLatestStudentLog(5, DateTime.Now);


                try
                {
                    var res = await CheckStudentInOrOut();

                    this.IsCheckedIn   = res.Item1;
                    this.CheckinStatus = res.Item2;

                    if (this.LatestLog != null)
                    {
                        this.TimeIn = this.LatestLog.TimeIn.ToString("g");
                    }
                }
                catch (Exception ex)
                {
                    Nav.ShowAlert("Error", "Could not check out student");
                }

                ConvertAndSetSuspendedVal();
                IsBusy = false;
            }
            catch (Exception ex)
            {
                var p = ex.Message;
                this.CheckinResult = ex.Message;
                this.IsBusy        = false;
                Nav.ShowAlert("Error", ex.Message);
            }
            finally
            {
                this.IsBusy = false;
            }
        }
예제 #10
0
        async Task Login()
        {
            IsBusy = true;
            K12RestApi api  = new K12RestApi();
            string     user = this.UserName;
            string     pwd  = this.Password;

            if (string.IsNullOrWhiteSpace(user) || string.IsNullOrWhiteSpace(pwd))
            {
                IsBusy = false;
                Nav.ShowAlert("Login failure", "Username and password cannot be blank.");

                return;
            }
            try
            {
                var credentials = api.PrepareCredentials(user, password);
                api.SetAuthToken(credentials);
                var isValid = await api.ValidateCredentials(credentials);

                if (isValid)
                {
                    api.SetAuthToken(credentials);
                    Nav.ExecuteNavigation();
                }
                else
                {
                    Nav.ShowAlert("Bad Login", "Username and/or password is incorrect.");
                }
            }
            catch (System.Exception ex)
            {
                string mm = ex.Message;
                Nav.ShowAlert("Error", mm);
            }

            finally
            {
                IsBusy = false;
            }
        }
예제 #11
0
        public BehaviorProfileViewModel(StudentDetails details, string reason)
        {
            try
            {
                this.BehaviorReason = reason;

                api          = new K12RestApi();
                this.Details = details;
                IsBusy       = true;

                GetStudentInfo(int.Parse(details.IDNumber));
                ConvertAndSetSuspendedVal();
                AddStudentBehavior();
            }
            catch (Exception ex)
            {
                var p = ex.Message;
                Nav.ShowAlert("Error", ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }