public DashboardViewModel()
 {
     GoSearchCommand = new Command <string>(x =>
     {
         Nav.ExecuteNavigation(x);
     });
 }
Exemple #2
0
        public async void AddStudentBehavior()
        {
            try
            {
                IsBusy = true;
                var sb = new StudentBehavior();

                sb.CCode       = Details.CCode;
                sb.CompID      = this.Details.CompID;
                sb.Type        = "";
                sb.Description = "";
                sb.TimeStamp   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                var btype = api.GetCurrentBehaviorType();
                sb.VltnTypID = btype.VltnTypID;
                var result = await api.AddStudentBehavior(sb);

                this.BehaviorReason = btype.Description;

                var um = "";
            }

            catch (Exception ex)
            {
                Nav.ShowAlert("Error", "Could not add behavior");
                Nav.ExecuteNavigation("back");
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #3
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;
            }
        }