<commit_before>var builder = require('botbuilder');
var logger = require('../../log4js').logger;
var prorigoRest = require('../prorigoRest');
var moment = require('moment');

var lib = new builder.Library('booking');

// lib.dialog('/ShowBookingStatus',[
//     function(session,args,next){
//     session.sendTyping();
//     var intent = args.intent;
//     var  = builder.EntityRecognizer.findEntity(intent.entities, 'Note.Title');

//     prorigoRest.getAllBookings(function(json){
//         var bookingMessage = createBookingMessage(session, json);
//         session.send(bookingMessage);
//         session.endDialog();
//     }, function(err){
//         logger.error(err);
//         session.endDialog('something_went_wrong');
//     },{userId : 'test', channelId: 'skype'});
// }]).triggerAction({
//     matches: 'ShowBookingStatus'
// });


lib.dialog('/CancelBooking',[function(session,args,next){
    session.sendTyping();
    prorigoRest.getMyBookings(function(jsonBody){
        if (jsonBody.length == 0){
            var showBookingsMessage = "You have no reserved room"
            session.send(showBookingsMessage)
        }else{
            var room_list = [];
            for (var i=0; i<jsonBody.length; i++){
                room_list[i] = jsonBody[i].room + "  "+ jsonBody[i].date + "  " + jsonBody[i].fromTime + " to " + jsonBody[i].toTime;
                }
                session.dialogData.room_list = jsonBody;
            builder.Prompts.choice(session, "Which room do you want to cancel?", room_list, {listStyle: 3})
            }
    }, function(err){
        logger.error(err);
        session.endDialog('something_went_wrong');
    },{userId : 'test', channelId: 'skype'});
},function(session,results){
    var meeting = session.dialogData.room_list[results.response.index];
    session.dialogData.meeting = meeting;
    var promptMsg1 = "Are you sure you want to cancel ";<commit_msg>adding showBookings dialog in bookings.js<commit_after>var builder = require('botbuilder');
var logger = require('../../log4js').logger;
var prorigoRest = require('../prorigoRest');
var moment = require('moment');

var lib = new builder.Library('booking');

lib.dialog('/ShowBookingStatus',[
    function(session,args,next){
    session.sendTyping();
    var intent = args.intent;

    if(intent.entities){
        if(builder.EntityRecognizer.findEntity(intent.entities, 'myBooking')){
            prorigoRest.getMyBookings(function(json){
                var bookingMessage = createBookingMessage(session, json);
                session.send(bookingMessage);
                session.endDialog();
            }, function(err){
                logger.error(err);
                session.endDialog('something_went_wrong');
            },{userId : 'test', channelId: 'skype'});
        }else{
            prorigoRest.getAllBookings(function(json){
                var bookingMessage = createBookingMessage(session, json);
                session.send(bookingMessage);
                session.endDialog();
            }, function(err){
                logger.error(err);
                session.endDialog('something_went_wrong');
            },{userId : 'test', channelId: 'skype'});
            } 
        }else{
            prorigoRest.getAllBookings(function(json){
                var bookingMessage = createBookingMessage(session, json);
                session.send(bookingMessage);
                session.endDialog();
            }, function(err){
                logger.error(err);
                session.endDialog('something_went_wrong');
            },{userId : 'test', channelId: 'skype'});
        }
}]).triggerAction({
    matches: 'ShowBookingStatus'
});

lib.dialog('/CancelBooking',[function(session,args,next){
    session.sendTyping();
    prorigoRest.getMyBookings(function(jsonBody){
        if (jsonBody.length == 0){
            var showBookingsMessage = "You have no reserved room"
            session.send(showBookingsMessage)
        }else{
            var room_list = [];
            for (var i=0; i<jsonBody.length; i++){
                room_list[i] = jsonBody[i].room + "  "+ jsonBody[i].date + "  " + jsonBody[i].fromTime + " to " + jsonBody[i].toTime;
                }
                session.dialogData.room_list = jsonBody;
            builder.Prompts.choice(session, "Which room do you want to cancel?", room_list, {listStyle: 3})
            }
    }, function(err){
        logger.error(err);
        session.endDialog('something_went_wrong');
    },{userId : 'test', channelId: 'skype'});
},function(session,results){
    var meeting = session.dialogData.room_list[results.response.index];
    session.dialogData.meeting = meeting;
    var promptMsg1 = "Are you sure you want to cancel ";
{'fraction_non_alphanumeric': 0.14565767284991568, 'fraction_numerical': 0.0021079258010118043, 'mean_word_length': 2.5516467065868262, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2615356', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1341, 'n_words': 244}