Пример #1
0
        private void Next_button_Click(object sender, RoutedEventArgs e)
        {
            login           = Login_textbox.Text;
            password        = Password_textbox.Password;
            confirmPassword = ConfirmPassword_textbox.Password;

            LoginPage loginPage = new LoginPage();

            if (Login.IsPasswordCorrect(password, confirmPassword) &&
                Login.IsCorrectLogin(login))
            {
                hashPassword = Login.HashPassword(password);
                try
                {
                    UsersRepos.CreateUser(login, hashPassword);
                }
                catch
                {
                    MessageBox.Show(Properties.Resources.errorCreateUser, Properties.Resources.warning);
                    return;
                }

                NavigationService.Navigate(loginPage);
            }
        }
Пример #2
0
        private void Apply_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Name          = Name_textbox.Text;
                Surname       = Surname_textbox.Text;
                Sex           = SexCheck;
                Age           = Convert.ToUInt32(Age_textbox.Text);
                Height        = Convert.ToDouble(Height_textbox.Text.Replace('.', ','));
                Weight        = Convert.ToDouble(Weight_textbox.Text.Replace('.', ','));
                ActivityLevel = Convert.ToUInt32(ActivityLevel_combobox.SelectedIndex);
                Goal          = Convert.ToUInt32(Goal_combobox.SelectedIndex);
                DietType      = Convert.ToUInt32(DietCheck());
                MealCount     = Convert.ToUInt32(MealsCount_combobox.SelectedItem);
                BMI           = MathOperations.getBMI(Height, Weight);
                BMR           = MathOperations.getBMR(Height, Weight, Convert.ToInt32(Age), Sex);
                TMR           = MathOperations.getTMR(Convert.ToInt32(ActivityLevel), BMR);
                DailyCalories = MathOperations.getDailyCalories(Convert.ToInt32(Goal), TMR);

                BMI_textblock.Text           = BMI.ToString("0.##");
                BMR_textblock.Text           = BMR.ToString();
                TMR_textblock.Text           = TMR.ToString();
                DailyCalories_textblock.Text = DailyCalories.ToString();

                Meals meals = new Meals(Convert.ToInt32(MealCount), DailyCalories,
                                        Convert.ToInt32(DietType), Convert.ToInt32(Goal), Weight);

                uint sex;
                if (Sex)
                {
                    sex = 1;
                }
                else
                {
                    sex = 0;
                }

                Users user = new Users(Login.UserLogin, Name, Surname, Age, Height, Weight, Goal,
                                       sex, ActivityLevel, DailyCalories, DietType, MealCount);

                UsersRepos.Update(user);
            }
            catch
            {
                MessageBox.Show(Properties.Resources.errorEmptyDatas, Properties.Resources.warning);
            }
            show();
        }
Пример #3
0
        public static string GetPassword(string login)
        {
            var    Users    = UsersRepos.GetAll();
            string password = "";

            foreach (var user in Users)
            {
                if (login == user.Login)
                {
                    password = user.Password;
                    break;
                }
            }

            return(password);
        }
        static void Main(string[] args)
        {
            using (DatabaseContext.DatabaseContext db = new DatabaseContext.DatabaseContext())
            {
                UsersRepos userRepos = new UsersRepos(db);
                var        users     = db.Users;

                foreach (Users u in users)
                {
                    Console.WriteLine($"{u.Id}.{u.Name}");
                }

                var photos = db.Photos;

                foreach (Photos photo in photos)
                {
                    Console.WriteLine($"Photo id: {photo.Id} by user {photo.UserId}.{userRepos.GetById(photo.UserId).Name}");
                }
            }
            Console.Read();
        }
Пример #5
0
        public void InitializeRepos(bool CheckInputs = true, bool AllowCascade = false)
        {
            UsersRepos          = new UsersRepos(cont, CheckInputs, AllowCascade);
            AddressRepos        = new AddressRepos(cont, CheckInputs, AllowCascade);
            HouseRepos          = new HouseRepos(cont, CheckInputs, AllowCascade);
            StreetRepos         = new StreetRepos(cont, CheckInputs, AllowCascade);
            CityRepos           = new CityRepos(cont, CheckInputs, AllowCascade);
            OrderRepos          = new OrderRepos(cont, CheckInputs, AllowCascade);
            CustomerRepos       = new CustomerRepos(cont, CheckInputs, AllowCascade);
            CompanyRepos        = new CompanyRepos(cont, CheckInputs, AllowCascade);
            OrderEntryRepos     = new OrderEntryRepos(cont, CheckInputs, AllowCascade);
            StatusRepos         = new StatusRepos(cont, CheckInputs, AllowCascade);
            MeterRepos          = new MeterRepos(cont, CheckInputs, AllowCascade);
            MeterTypeRepos      = new MeterTypeRepos(cont, CheckInputs, AllowCascade);
            StavkaRepos         = new StavkaRepos(cont, CheckInputs, AllowCascade);
            PersonRepos         = new PersonRepos(cont, CheckInputs, AllowCascade);
            UserToCustomerRepos = new UserToCustomerRepos(cont, CheckInputs, AllowCascade);

            Reposes = new Dictionary <Type, object>()
            {
                { typeof(Address), AddressRepos },
                { typeof(House), HouseRepos },
                { typeof(Street), StreetRepos },
                { typeof(City), CityRepos },
                { typeof(Order), OrderRepos },
                { typeof(OrderEntry), OrderEntryRepos },
                { typeof(Customer), CustomerRepos },
                { typeof(Company), CompanyRepos },
                { typeof(User), UsersRepos },
                { typeof(Meter), MeterRepos },
                { typeof(MeterType), MeterTypeRepos },
                { typeof(Status), StatusRepos },
                { typeof(Person), PersonRepos },
                { typeof(Stavka), StavkaRepos },
                { typeof(UserToCustomer), UserToCustomerRepos },
            };
        }
Пример #6
0
        private void SetData()
        {
            var UserList = UsersRepos.GetAll();

            Users User = null;

            foreach (var user in UserList)
            {
                if (Login.UserLogin == user.Login)
                {
                    User = new Users(user);
                    break;
                }
            }

            if (User != null)
            {
                Name_textbox.Text                    = User.Name;
                Surname_textbox.Text                 = User.Surname;
                Age_textbox.Text                     = User.Age.ToString();
                Height_textbox.Text                  = User.Height.ToString();
                Weight_textbox.Text                  = User.Weight.ToString();
                DailyCalories_textblock.Text         = User.Kcal.ToString();
                MealsCount_combobox.SelectedItem     = Convert.ToInt32(User.MealsCount);
                ActivityLevel_combobox.SelectedIndex = Convert.ToInt32(User.ActivityLevel);
                Goal_combobox.SelectedIndex          = Convert.ToInt32(User.Goal);

                if (User.Sex == 0)
                {
                    woman_radiobutton.IsChecked = true;
                    Sex = false;
                }
                if (User.Sex == 1)
                {
                    man_radiobutton.IsChecked = true;
                    Sex = true;
                }

                if (User.DietType == 0)
                {
                    normal_radiobutton.IsChecked = true;
                }
                if (User.DietType == 1)
                {
                    vegetarian_radiobutton.IsChecked = true;
                }
                if (User.DietType == 2)
                {
                    vegan_radiobutton.IsChecked = true;
                }

                Height        = Convert.ToDouble(User.Height);
                Weight        = Convert.ToDouble(User.Weight);
                Age           = Convert.ToUInt32(User.Age);
                ActivityLevel = Convert.ToUInt32(User.ActivityLevel);
                DietType      = Convert.ToUInt32(DietCheck());

                BMI = MathOperations.getBMI(Height, Weight);
                BMR = MathOperations.getBMR(Height, Weight, Convert.ToInt32(Age), Sex);
                TMR = MathOperations.getTMR(Convert.ToInt32(ActivityLevel), BMR);

                BMI_textblock.Text = BMI.ToString("0.##");
                BMR_textblock.Text = BMR.ToString();
                TMR_textblock.Text = TMR.ToString();

                Login.CurrentUser = User;
            }
        }