private static string GetAnswer(AliceRequest aliceRequest, BoxesContext dataBase, User user)
        {
            var requestMode = GetRequestMode(aliceRequest, user);

            switch (requestMode)
            {
            case RequestModes.Hello:
                return(TextResources.Hello);

            case RequestModes.Help:
                return(TextResources.Help);

            case RequestModes.OpenBox:
                EntitiesConvertExtension.TryParseInt(aliceRequest.request, out var number);
                dataBase.SetOpenedBoxNumber(user.UserId, number);
                var message = Regex.Replace(dataBase.ReadFromBox(number), @"\t|\n|\r", string.Empty);
                return(message.Length == 0 ? GetRandomString(TextResources.BoxIsEmpty)
                                               : $"{GetRandomString(TextResources.MessageInTheBox)}. {message}");

            case RequestModes.Repeat:
                message = Regex.Replace(dataBase.ReadFromBox(user.OpenedBox), @"\t|\n|\r", string.Empty);
                return(message.Length == 0 ? $"{TextResources.Repeat} {GetRandomString(TextResources.BoxIsEmpty)}"
                                               : $"{TextResources.Repeat} {GetRandomString(TextResources.MessageInTheBox)}. {message}");

            case RequestModes.SaveToBox:
                dataBase.SetUserSaveMode(user.UserId, true);
                return(GetRandomString(TextResources.SaveToBox));

            case RequestModes.Dictate:
                var maxLength = 300;

                message = Regex.Replace(
                    aliceRequest.request.original_utterance.Length <= maxLength
                            ? aliceRequest.request.original_utterance
                            : aliceRequest.request.original_utterance.Substring(0, maxLength), @"\t|\n|\r", string.Empty);

                dataBase.SaveToBox(user.OpenedBox, message);
                dataBase.SetUserSaveMode(user.UserId, false);
                return($"{GetRandomString(TextResources.MessageSaved)} {user.OpenedBox}");

            case RequestModes.Read:
                message = Regex.Replace(dataBase.ReadFromBox(user.OpenedBox), @"\t|\n|\r", string.Empty);
                return(message.Length == 0 ? GetRandomString(TextResources.BoxIsEmpty)
                                               : $"{GetRandomString(TextResources.MessageInTheBox)}. {message}");

            case RequestModes.DeleteMessage:
                dataBase.SaveToBox(user.OpenedBox, string.Empty);
                return(GetRandomString(TextResources.DeleteMessage));

            case RequestModes.BoxIsNotOpen:
                return(TextResources.BoxIsNotOpen);

            case RequestModes.InvalidBoxNumber:
                return(GetRandomString(TextResources.WrongNumberOfBox));

            default:
                return(GetRandomString(TextResources.SomethingWrong));
            }
        }
        public static AliceResponse MakeResponse(AliceRequest aliceRequest, BoxesContext dataBase)
        {
            var user = dataBase.GetUserById(aliceRequest.session.session_id);

            var session = new SessionResponse
            {
                session_id = aliceRequest.session.session_id,
                message_id = aliceRequest.session.message_id,
                user_id    = aliceRequest.session.user_id
            };

            var aliceResponse = new AliceResponse {
                session = session
            };

            aliceResponse.response.text        = GetAnswer(aliceRequest, dataBase, user);
            aliceResponse.response.tts         = aliceResponse.response.text;
            aliceResponse.response.end_session = false;

            return(aliceResponse);
        }