public ChatItem GetUserChatItem(string userId, string query)
 {
     ChatItem chatItem = new ChatItem();
     chatItem.Id = userId;
     chatItem.ChatText = query;
     return chatItem;
 }
        static void CreateSampleAnswer()
        {
            ChatItem item1 = new ChatItem();
            item1.Id = "Cortana";
            item1.ChatText = "Hi this is Cortana";

            ChatItem item2 = new ChatItem();
            item2.Id = "User";
            item2.ChatText = "Hi this is User";

            ChatItem item3 = new ChatItem();
            item3.Id = "Cortana";
            item3.ChatText = "Hi shall we complete the Task?";

            ChatWindow chatWindow = new ChatWindow();
            chatWindow.ChatList.Add(item1);
            chatWindow.ChatList.Add(item2);
            chatWindow.ChatList.Add(item3);

            TrainBookingState bookingState = new TrainBookingState();

            bookingState.Source = new Station();
            bookingState.Source.Name = "Hyderabad";
            bookingState.Source.Code = "SC";

            bookingState.Destination = new Station();
            bookingState.Destination.Name = "Chennai Central";
            bookingState.Destination.Code = "MAS";

            bookingState.DateOfJourney = DateTime.Now.AddDays(10);

            bookingState.TrainInfo = new TrainInfo();
            bookingState.TrainInfo.Name = "Chennai Express";
            bookingState.TrainInfo.Number = "12604";

            bookingState.CoachPreference = CoachType.SecondAC;
            bookingState.PhoneNumber = "1234567890";

            bookingState.NumberOfPassangers = 4;

            PassangerInfo pas1 = new PassangerInfo();
            pas1.Name = "BillGates";
            pas1.Age = 50;
            pas1.Gender = Gender.Male;
            pas1.BerthChoice = BerthChoice.SideLower;

            PassangerInfo pas2 = new PassangerInfo();
            pas2.Name = "Balmer";
            pas2.Age = 49;
            pas2.Gender = Gender.Male;
            pas2.BerthChoice = BerthChoice.SideUpper;

            PassangerInfo pas3 = new PassangerInfo();
            pas3.Name = "BillGates";
            pas3.Age = 45;
            pas3.Gender = Gender.Male;
            pas3.BerthChoice = BerthChoice.Lower;

            bookingState.PassangerInfoList = new List<PassangerInfo>();
            bookingState.PassangerInfoList.Add(pas1);
            bookingState.PassangerInfoList.Add(pas2);
            bookingState.PassangerInfoList.Add(pas3);


            TaskAnswer answer = new TaskAnswer();
            answer.Title = "Book Train Ticket Task";
            answer.TaskType = TaskType.Train;
            answer.ChatWindow = chatWindow;
            answer.TaskState = bookingState;


            string jsonString = JsonConvert.SerializeObject(answer);

            return;



        }
        private ChatItem GetChatItem(TaskAnswer answer, TaskStateCode stateCode)
        {
            TrainBookingState taskState = answer.TaskState as TrainBookingState;
            if (taskState == null)
            {
                return null;
            }

            string question;
            if (!_chatItemMap.TryGetValue(stateCode, out question))
            {
                question = "Some Error. it shouldn't";
            }

            ChatItem item = new ChatItem();
            item.Id = "Cortana";
            item.ChatText = question;
            return item;
        }
        private void FillePreferredBerthList(ChatItem chatItem)
        {
            List<string> chatList = new List<string>();
            chatList.Add("SU");
            chatList.Add("SL");
            chatList.Add("L");
            chatList.Add("M");
            chatList.Add("U");
            chatList.Add("NC");

            chatItem.ChatList = chatList;
            chatItem.ListType = ChatListType.Column;
        }
        private void FillPreferredCoachList(ChatItem chatItem)
        {
            List<string> chatList = new List<string>();
            chatList.Add("1 AC");
            chatList.Add("2 AC");
            chatList.Add("3 AC");
            chatList.Add("SL");

            chatItem.ChatList = chatList;
            chatItem.ListType = ChatListType.Column;
        }
 private void FillTrainList(ChatItem chatItem, string source, string destination)
 {
     List<Train> trainDataList = TrainUtil.DownlondJsonFromUrl(source, destination);
     List<string> stringList = TrainUtil.ConvertTrainDataListToStringList(trainDataList);
    
     chatItem.ChatList = stringList;
     chatItem.ListType = ChatListType.Row;
 }
        private TaskAnswer PostStateAction(TaskAnswer answer, UserProfile profile, string query)
        {
            TrainBookingState taskState = answer.TaskState as TrainBookingState;
            if (taskState == null)
            {
                return null;
            }

            TaskStateCode nextState = GetNextState(answer);
            answer.CurrentState = nextState;

            string question;
            if (!_chatItemMap.TryGetValue(nextState, out question))
            {
                question = "Some Error. it shouldn't";
                return null;
            }
            ChatItem chatItem = new ChatItem();
            PassangerInfo passenger = taskState.PassangerInfoList.FirstOrDefault(x => x.Id == answer.CurrentPassengerId);
            if (passenger == null)
            {
                // Fixme; avoid dummy passenger
                PassangerInfo passanger = new PassangerInfo();
            }
            
            switch (nextState)
            {
                case TaskStateCode.InitState:
                    break;
                case TaskStateCode.SourceStationState:
                    break;
                case TaskStateCode.DestinationStationState:
                    break;
                case TaskStateCode.DateOfJourneyState:
                    break;
                case TaskStateCode.TrainSelectionState:
                    question = string.Format(question, taskState.Source.Code, taskState.Destination.Code);
                    FillTrainList(chatItem, taskState.Source.Code, taskState.Destination.Code);
                    break;
                case TaskStateCode.PreferredCoachState:
                    FillPreferredCoachList(chatItem);
                    break;
                case TaskStateCode.NumberOfPassangersState:
                    break;
                case TaskStateCode.PassengerNameState:
                    question = string.Format(question, answer.CurrentPassengerId);
                    break;
                case TaskStateCode.PassengerGenderState:
                    question = string.Format(question, passenger.Name);
                    break;
                case TaskStateCode.PassengerAgeState:
                    question = string.Format(question, (passenger.Gender.Equals(Gender.Male)) ? "his" : "her");
                    break;
                case TaskStateCode.PassengerSeatPreferenceState:
                    FillePreferredBerthList(chatItem);
                    break;
                case TaskStateCode.PassengerDetailsState:
                    break;
                case TaskStateCode.PhoneNumberState:
                    break;
                case TaskStateCode.BookTicketState:
                    break;
                case TaskStateCode.EndState:
                    profileHelper.UpdateUserProfile(taskState, profile);
                    break;
                default:
                    break;
            }

            chatItem.Id = "Cortana";
            chatItem.ChatText = question;
            answer.ChatWindow.ChatList.Add(chatItem);
            return answer;
        }