Esempio n. 1
0
 public WorkoutViewModel(User user, DashboardWindowViewModel dashboardWindowViewModel)
 {
     _myWellnessAppBusiness    = new MyWellnessAppBusiness();
     _dashboardWindowViewModel = dashboardWindowViewModel;
     _currentUser         = user;
     _currentUserWorkouts = new ObservableCollection <PhysicalActivity>(CurrentUser.PhysicalActivities);
     _categoryForFilter   = new ObservableCollection <string>(Enum.GetNames(typeof(PhysicalActivity.ExerciseType)));
 }
        /// <summary>
        /// login to the wellness app by retrieving user
        /// </summary>
        private void Login(object obj)
        {
            Message = null;
            MyWellnessAppBusiness myWellnessAppBusiness = new MyWellnessAppBusiness();
            //List<User> user = myWellnessAppBusiness.RetreiveAllUserFromDataPath();
            List <User> user = myWellnessAppBusiness.GetAllUsers();

            if (!String.IsNullOrEmpty(InputUsername) && !String.IsNullOrEmpty(InputPassword))
            {
                foreach (var u in user)
                {
                    try
                    {
                        if (u.UserName == InputUsername && u.Password == InputPassword)
                        {
                            DashboardWindowViewModel dashboardWindowViewModel = new DashboardWindowViewModel(myWellnessAppBusiness.GetUser(u.ID));
                            DashboardWindow          dashboardWindow          = new DashboardWindow();

                            dashboardWindow.DataContext = dashboardWindowViewModel;
                            dashboardWindow.Show();

                            if (obj is System.Windows.Window)
                            {
                                (obj as System.Windows.Window).Close();
                            }
                        }
                        else
                        {
                            Message = "INCORRECT USERNAME OR PASSWORD";
                        }
                    }
                    catch (Exception e)
                    {
                        string m = e.Message;
                        throw;
                    }
                }
            }
            else
            {
                Message = "PLEASE VERIFY THAT YOU HAVE ENTER THE CORRECT USERNAME AND PASSWORD";
            }
        }