예제 #1
0
 private void Start_Click(object sender, RoutedEventArgs e)
 {
     StartMain.Invoke(sender, e);
 }
예제 #2
0
 private void Start()
 {
     Instance = this;
     num.text = XMLData.GameDatas[0].score + "";
 }
예제 #3
0
        public Fsm(long chatId, Message msg, TelegramBotClient bot, Context db)
        {
            User state;

            lock (Locker)
            {
                state = db.Users.FirstOrDefault(x => x.ChatId == chatId);
            }

            if (state == null)
            {
                User user = new User
                {
                    ChatId = chatId,
                    State  = StateChatEnum.StartMain
                };
                db.Users.Add(user);
                db.SaveChanges();
            }

            if (state != null)
            {
                IUpdateState updateState;

                switch (state.State)
                {
                case StateChatEnum.StartMain:
                    var uid = db.Users.FirstOrDefault(x => x.ChatId == chatId);
                    if (uid == null)
                    {
                        User user = new User
                        {
                            ChatId = chatId,
                            State  = StateChatEnum.StartText
                        };

                        db.Users.Add(user);
                        db.SaveChanges();
                    }

                    updateState = new StartMain();
                    break;

                case StateChatEnum.EndAddress:
                    updateState = new EndAddress();
                    break;

                case StateChatEnum.StartText:
                    updateState = new StartText();
                    break;

                case StateChatEnum.SendingTime:
                    updateState = new SendingTime();
                    break;

                case StateChatEnum.SendingNumberPhone:
                    updateState = new SendingNumberPhone();
                    break;

                case StateChatEnum.PaymentMethod:
                    updateState = new PaymentMethod();
                    break;

                case StateChatEnum.CarSearch:
                    updateState = new CarSearch();
                    break;

                //case StateChatEnum.CarSearch:
                //	updateState = new CarSearch();
                //	break;

                default:
                    throw new AggregateException();
                }

                updateState.UpdateAsync(msg, bot, chatId, db);
            }
        }