Exemplo n.º 1
0
        private void SetupBioScreenView(IUserEntitie loggedInUser, Window window)
        {
            this.appViews.BioScreen.Add(new Label(10, 3, "Welcome " + loggedInUser.Username)
            {
                TextAlignment = TextAlignment.Centered
            });
            window.Add(this.appViews.BioScreen);

            this.appViews.BioScreen.ConfirmButton.Clicked += () =>
            {
                BioDataEntitie newBioData = new BioDataEntitie
                {
                    Age       = int.Parse(this.appViews.BioScreen.AgeTextField.Text.ToString()),
                    Weight    = double.Parse(this.appViews.BioScreen.WeightTextField.Text.ToString()),
                    Height    = double.Parse(this.appViews.BioScreen.HeightTextField.Text.ToString()),
                    NeckSize  = double.Parse(this.appViews.BioScreen.NeckSizeeTextField.Text.ToString()),
                    WaistSize = double.Parse(this.appViews.BioScreen.WaistSizeTextField.Text.ToString()),
                    HipsSize  = double.Parse(this.appViews.BioScreen.HipsSizeTextField.Text.ToString()),
                    Gender    = int.Parse(this.appViews.BioScreen.GenderRadioGroup.Selected.ToString())
                };

                loggedInUser.BioData = newBioData;
                userService.UpdateUser(loggedInUser);

                window.Remove(this.appViews.BioScreen);
                window.Add(this.appViews.ChooseGoalScreen);
                this.appViews.ChooseGoalScreen.SetFocus(this.appViews.ChooseGoalScreen.RadioGroup);

                Application.Run(window);
            };
        }
Exemplo n.º 2
0
 public void Add(IUserEntitie entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("User cannot be null!");
     }
     this.FakeLiteDb.Add(entity);
 }
Exemplo n.º 3
0
        public void UpdateUser(IUserEntitie loggedInUser)
        {
            if (loggedInUser == null)
            {
                throw new ArgumentNullException("User cannot be null!");
            }

            db.UserRepository.Update(loggedInUser);
        }
Exemplo n.º 4
0
        public void Register(IUserEntitie userToCreate)
        {
            if (userToCreate == null)
            {
                throw new ArgumentNullException("User cannot be null!");
            }

            db.UserRepository.Add(userToCreate);
        }
Exemplo n.º 5
0
        public void Update(IUserEntitie entity)
        {
            using (var db = new LiteDatabase(connectionString))
            {
                var collection = db.GetCollection <IUserEntitie>(typeof(IUserEntitie).Name);

                collection.Update(entity);
            }
        }
Exemplo n.º 6
0
        public void Add(IUserEntitie entity)
        {
            using (var db = new LiteDatabase(connectionString))
            {
                var collection = db.GetCollection <IUserEntitie>(typeof(IUserEntitie).Name);

                collection.Insert(collection.Max("_id").AsInt32 + 1, entity);
            }
        }
Exemplo n.º 7
0
        public void Update(IUserEntitie entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("User cannot be null!");
            }

            var user = this.FakeLiteDb.Find(u => u.Username == entity.Username);

            this.FakeLiteDb.Remove(user);
            this.FakeLiteDb.Add(entity);
        }
Exemplo n.º 8
0
        private void SetupLoginScreenLoginButtonAction(Window window)
        {
            this.appViews.LoginScreen.LoginButton.Clicked += () =>
            {
                // Try to get existing user
                loggedInUser = userService.Login(this.appViews.LoginScreen.UsernameField.Text.ToString(), this.appViews.LoginScreen.PasswordField.Text.ToString());

                // Successfull login
                if (loggedInUser != null)
                {
                    this.HandleSuccessfulLogin(window);
                }
                // Login failed
                else
                {
                    this.SetupFailedLoginDialogPopUp();
                }
            };
        }
Exemplo n.º 9
0
 public void Delete(IUserEntitie entity)
 {
     throw new NotImplementedException();
 }