Example #1
0
        // Перегрузка метода IsExistId
        private bool IsExistId(int id)
        {
            string jsonContent = File.ReadAllText("UserBiblio.json");

            jsonIdDelete = JsonMapper.ToObject(jsonContent);

            for (int i = 0; i < jsonIdDelete.Count; i++)
            {
                if (jsonIdDelete[i]["IDProp"].ToString() == UserWindow.GetMd5Hash(hash, id.ToString()))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        // Проверка существования пользователя с таким именем
        private bool IsExistUserName(string isNameExist)
        {
            if (jsonItem == null)
            {
                jsonItem = JsonMapper.ToObject(jsonTextBox);
            }

            for (int i = 0; i < jsonItem.Count; i++)
            {
                if (jsonItem[i]["UsernameProp"].ToString() == UserWindow.GetMd5Hash(hash, isNameExist))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        //Создание нового пользователя методом занесения данных в формате JSON  в виде массива

        private void createUser_Click(object sender, RoutedEventArgs e)
        {
            if (IsExistUserName(username.Text))
            {
                MessageBox.Show("The user with such username has been already existed!", "InvalidRegistration");
            }
            else
            {
                OriginInitiating();
                massiveCapacity++;
                newUserNext = new ClassUser[massiveCapacity];

                if (newUser != null)
                {
                    for (int i = 0; i < newUser.Length; i++)
                    {
                        newUserNext[i] = newUser[i];
                    }
                }

                int randNumber = rand.Next(idCapacity);
                while (IsExistId(randNumber))
                {
                    randNumber = rand.Next(idCapacity);
                }

                newUserNext[massiveCapacity - 1] = new ClassUser(randNumber, UserWindow.GetMd5Hash(hash, username.Text), UserWindow.GetMd5Hash(hash, password.Text), Int32.Parse(balance.Text), GetNewImagePath());
                jsonItem = JsonMapper.ToJson(newUserNext);
                File.WriteAllText("UserBiblio.json", jsonItem.ToString());
                newUser = newUserNext;
                MessageBoxResult result = MessageBox.Show("You have been successfully registrated!", "ValidRegistration", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                    nav.Navigate(new Uri("EnterTheCabinet.xaml", UriKind.RelativeOrAbsolute));
                }
            }
        }