Пример #1
0
        public void CheckPlyer(TextBox TextName, TextBlock TextListPlyer)
        {
            CodeFirst         context    = new CodeFirst();
            IEnumerable <int> firstPlyer = unit.Sql.queryToUsersFirst();

            IEnumerable <int> secondPlyer = unit.Sql.CheckPlyer(TextName.Text);

            int value = secondPlyer.Count();

            foreach (int first in firstPlyer)
            {
                foreach (int second in secondPlyer)
                {
                    Play plyers = new Play();
                    plyers.FirstId  = first;
                    plyers.SecondId = second;
                    plyers.Start    = false;
                    unit.Sql.AddToPlay(plyers);
                }
            }
            unit.Sql.SaveToDB();

            if (value == 1)
            {
                TextListPlyer.Text = "Wait support second plyer!";
                TextName.Clear();
            }
            else
            {
                TextName.Text = "Try again! False data!";
            }
        }
Пример #2
0
        public void CheckDatabase(TextBlock Result)
        {
            CodeFirst         context = new CodeFirst();
            int               index   = 0;
            IEnumerable <int> user    = unit.Sql.queryToUsersFirst();

            foreach (int i in user)
            {
                index = i;
            }
            if (CheckPlayDB(index) && CheckPlayResult(index) > 0)
            {
                Result.Text = "Time is over. You won! Congratulations !";
            }
            else
            {
                if (CheckPlayResult(index) == 0)
                {
                    Result.Text = "Time is over. You have a draw.";
                }
                if (!CheckPlayDB(index) && CheckPlayResult(index) < 0)
                {
                    Result.Text = "Time is over. You won! Congratulations !";
                }
                if (!CheckPlayDB(index) && CheckPlayResult(index) > 0)
                {
                    Result.Text = "Time is over. You lose. Try again !";
                }
            }
            if (CheckPlayDB(index) && CheckPlayResult(index) < 0)
            {
                Result.Text = "Time is over. You lose. Try again !";
            }
            Delete();
        }
Пример #3
0
        public void Delete()
        {
            WorkWithAgreeOtherPlyer work = new WorkWithAgreeOtherPlyer();
            CodeFirst context            = new CodeFirst();
            Play      play = context.Play
                             .Where(o => o.FirstId == work.queryToUsersSecond(work.queryToUsersFirst()) && o.SecondId == work.queryToUsersFirst())
                             .FirstOrDefault();

            context.Play.Remove(play);
            context.SaveChanges();
        }
Пример #4
0
        public void CheckDatabase(TextBlock ActveListBox)
        {
            CodeFirst            context      = new CodeFirst();
            IEnumerable <int>    query        = unitOfWork.Sql.CheckDatabase();
            CodeFirst            context2     = new CodeFirst();
            IEnumerable <string> queryToWords = unitOfWork.Sql.ConnectWithCheckDatabase();

            foreach (string str in queryToWords)
            {
                ActveListBox.Text = str + "\n";
            }
        }
Пример #5
0
        public int CheckPlayResult(int index)
        {
            int               resultWinner = 0;
            CodeFirst         context      = new CodeFirst();
            IEnumerable <int> result       = unit.Sql.CheckPlayResult(index);

            foreach (int i in result)
            {
                resultWinner = i;
            }
            return(resultWinner);
        }
Пример #6
0
        public bool CheckPlayDB(int index)
        {
            CodeFirst         context = new CodeFirst();
            IEnumerable <int> result  = unit.Sql.CheckPlayDB(index);

            if (result.Count() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
        public int CheckDate(int index)
        {
            int       countDay          = 0;
            CodeFirst context           = new CodeFirst();
            IEnumerable <DateTime> date = unit.Sql.CheckDate(index);

            foreach (DateTime now in date)
            {
                DateTime firstDate   = now;
                DateTime currentDate = DateTime.Today;
                TimeSpan span        = currentDate - firstDate;
                string   relative    = span.Days.ToString();
                countDay = Convert.ToInt32(relative);
            }
            return(countDay);
        }
Пример #8
0
        public void CheckPlyer(Label CheckLablel, Label LabelError, TextBox TextName, TextBox TextPassword)
        {
            CheckLablel.Visibility = System.Windows.Visibility.Hidden;
            LabelError.Visibility  = System.Windows.Visibility.Hidden;
            CodeFirst           context   = new CodeFirst();
            IEnumerable <Users> checkEnum = unit.Sql.CheckPlyer();
            bool flag             = false;
            bool flasgForPassword = false;

            foreach (Users str in checkEnum)
            {
                if (str.UserName == TextName.Text)
                {
                    flag = true;
                    if (true == HashPassword.VerifyHashedPassword(str.password, TextPassword.Text))
                    {
                        flasgForPassword = true;
                    }
                }
            }
            if (flag == false)
            {
                LabelError.Foreground = System.Windows.Media.Brushes.Red;
                LabelError.Content    = "Имя не найдено";
                LabelError.Visibility = System.Windows.Visibility.Visible;
            }
            if (flasgForPassword == false)
            {
                LabelError.Foreground = System.Windows.Media.Brushes.Red;
                LabelError.Content    = "Пароль неверный!";
                LabelError.Visibility = System.Windows.Visibility.Visible;
            }
            if (flag && flasgForPassword)
            {
                flag = CheckPassword(TextName.Text, CheckLablel);
                if (flag)
                {
                    WorkWithLearnWords.j = 0;
                    Users.aktivePlyer    = TextName.Text;
                }
                LabelError.Content    = "Добро пожаловать!!!";
                LabelError.Foreground = System.Windows.Media.Brushes.Blue;
                LabelError.Visibility = System.Windows.Visibility.Visible;
                TextName.Text         = "";
                TextPassword.Text     = "";
            }
        }
Пример #9
0
        public static bool CheckPassword(string userName, Label CheckLablel)
        {
            bool                 flag      = true;
            CodeFirst            context   = new CodeFirst();
            IEnumerable <string> checkEnum = from u in context.Users
                                             where u.UserName == userName
                                             select u.password;

            if (checkEnum.Count() == 0)
            {
                flag = false;
                CheckLablel.Content    = "Пароль введён неверно";
                CheckLablel.Visibility = System.Windows.Visibility.Visible;
                CheckLablel.Foreground = System.Windows.Media.Brushes.Red;
            }
            return(flag);
        }
Пример #10
0
        public void Delete()
        {
            CodeFirst         context = new CodeFirst();
            IEnumerable <int> indexes = unit.Sql.queryToUsersFirst();

            int index = 0;

            foreach (int i in indexes)
            {
                index = i;
            }
            Play play = context.Play
                        .Where(o => o.SecondId == index || o.FirstId == index)
                        .FirstOrDefault();

            context.Play.Remove(play);
            context.SaveChanges();
        }
Пример #11
0
        public bool CheckNewLevel(string level)
        {
            CodeFirst code = new CodeFirst();

            IEnumerable <Users> user = from u in code.Users
                                       where u.UserName == Users.aktivePlyer
                                       select u;

            foreach (Users i in user)
            {
                bool flag = Comparator(i.level, level);
                if (i.level == "NULL" || flag == true)
                {
                    sendMessage(i.email, level);
                    IEnumerable <Users> usersList = unit.Sql.CheckNewLevel(level);
                    return(true);
                }
            }
            return(false);
        }
Пример #12
0
        public int CheckOnAgree()
        {
            CodeFirst         context  = new CodeFirst();
            int               index    = -1;
            IEnumerable <int> idSecond = unit.Sql.queryToUsersFirst();

            foreach (int i in idSecond)
            {
                index = i;
            }
            IEnumerable <Play> play = unit.Sql.CheckOnAgree(index);

            IEnumerable <Play> playSituation2 = unit.Sql.CheckOnAgree2(index);

            IEnumerable <Play> playSituation3 = unit.Sql.CheckOnAgree3(index);

            IEnumerable <Play> playSituation4 = unit.Sql.CheckOnAgree4(index);

            if (play.Count() > 0)
            {
                return(0);
            }
            if (playSituation2.Count() > 0)
            {
                return(-1);
            }
            if (playSituation3.Count() > 0)
            {
                return(1);
            }
            if (playSituation4.Count() > 0)
            {
                return(1);
            }
            if (CheckDate(index) > 0)
            {
                return(2);
            }
            return(-2);
        }
Пример #13
0
        public void CanUseBuutonPlay(MenuItem Play)
        {
            CodeFirst         context      = new CodeFirst();
            CodeFirst         context2     = new CodeFirst();
            int               id           = 0;
            IEnumerable <int> idActiveUser = unit.Sql.queryToUsersFirst();

            foreach (int i in idActiveUser)
            {
                id = i;
            }
            IEnumerable <UsersWords> words = unit.Sql.CanUseBuutonPlay(id);

            if (words.Count() == 0 || id == 0)
            {
                Play.IsEnabled = false;
            }
            else
            {
                Play.IsEnabled = true;
            }
        }
Пример #14
0
        public void DownladContent(Button Check, TextBlock TextListPlyer)
        {
            Check.IsEnabled = false;
            CodeFirst context  = new CodeFirst();
            CodeFirst context1 = new CodeFirst();
            CodeFirst context2 = new CodeFirst();

            TextListPlyer.Text = "";
            IEnumerable <int> idActivePlyer = unit.Sql.queryToUsersFirst();

            IEnumerable <UsersWords> wordActiveCount = unit.Sql.DownladContent();

            IEnumerable <UsersWords> wordsOtherUsers = unit.Sql.DownladContent2();

            var count = from p in wordsOtherUsers
                        group p by p.UserId into g
                        select new
            {
                Name  = g.Key,
                Count = g.Count()
            };

            foreach (var u in count)
            {
                if (wordActiveCount.Count() == u.Count)
                {
                    IEnumerable <string> NameOtherPlyer = from f in context.Users
                                                          where f.UserId == u.Name
                                                          select f.UserName;
                    foreach (string name in NameOtherPlyer)
                    {
                        TextListPlyer.Text += name + "\n";
                    }
                }
            }
        }
Пример #15
0
 public QuerysToSql(CodeFirst context, CodeFirst context2, CodeFirst context3)
 {
     this.db  = context;
     this.db2 = context2;
     this.db3 = context3;
 }