-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove trailing return character Introduces factory for Handlers Introduces PostMessageOnEnterKey
- Loading branch information
Vinod
committed
Aug 3, 2019
1 parent
b446ba9
commit e0eff4c
Showing
14 changed files
with
129 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Alice.Common | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Alice.Common; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace RoomBookingExtension | ||
{ | ||
class AliceRepeatBookingRequestHandler : IInternalRequestHandler | ||
{ | ||
BookingRepository _bookingRepository; | ||
|
||
public AliceRepeatBookingRequestHandler(BookingRepository bookingRepository) | ||
{ | ||
_bookingRepository = bookingRepository; | ||
} | ||
|
||
public IAliceResponse Handle(IAliceRequest aliceRequest) | ||
{ | ||
BookingRequestsBuilder requestsBuilder = new BookingRequestsBuilder(aliceRequest.Parameters, aliceRequest.UserProfile); | ||
BookingRequest bookingRequest; | ||
bookingRequest = requestsBuilder.Build(); | ||
|
||
Booking booking; | ||
IAliceResponse response = new AliceResponse(); | ||
try | ||
{ | ||
booking = _bookingRepository.Book(bookingRequest); | ||
response.Message = string.Format("{0} was booked by you from {1} for {2}", booking.RoomName, booking.BookRangeLocalToString(aliceRequest.UserProfile.TimeZoneInfo), booking.BookedForToString()); | ||
} | ||
catch (Exception ex) | ||
{ | ||
response.StatusCode = System.Net.HttpStatusCode.BadRequest; | ||
response.Message = ex.Message; | ||
} | ||
|
||
return response; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace RoomBookingExtension | ||
{ | ||
class InternalRequestHandlerFactory | ||
{ | ||
private BookingRepository _bookingRepository; | ||
private RoomRepository _roomRepository; | ||
private Dictionary<string, Func<IInternalRequestHandler>> _handlers; | ||
|
||
public InternalRequestHandlerFactory(BookingRepository bookingRepository, RoomRepository roomRepository) | ||
{ | ||
_bookingRepository = bookingRepository; | ||
_roomRepository = roomRepository; | ||
_handlers = new Dictionary<string, Func<IInternalRequestHandler>>(); | ||
|
||
_handlers.Add("listrooms", () => { return new AliceListRoomsRequestHandler(_roomRepository); }); | ||
_handlers.Add("listbookings", () => { return new AliceBookingListRequestHandler(_bookingRepository); }); | ||
_handlers.Add("listmybookings", () => { return new AliceMyBookingListRequestHandler(_bookingRepository); }); | ||
_handlers.Add("bookroom", () => { return new AliceBookRoomRequestHandler(_bookingRepository); }); | ||
_handlers.Add("cancelbooking", () => { return new AliceCancelBookingRequestHandler(_bookingRepository); }); | ||
_handlers.Add("suggestcancellations", () => { return new AliceCancelBookingSuggestionRequestHandler(_bookingRepository); }); | ||
_handlers.Add("unrecognized", () => { return new AliceUnrecognizedRequestHandler(); }); | ||
} | ||
|
||
public IInternalRequestHandler GetInternalRequestHandler(string requestText) | ||
{ | ||
if (_handlers.ContainsKey(requestText)) | ||
return _handlers[requestText](); | ||
|
||
return _handlers["unrecognized"](); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"UserMessage":"how are you","InstanceCount":3},{"UserMessage":"Cancel my booking on 22 from 4 of room 1","InstanceCount":3},{"UserMessage":"tes 2","InstanceCount":1},{"UserMessage":"test 3","InstanceCount":2},{"UserMessage":"1","InstanceCount":1},{"UserMessage":"2","InstanceCount":1},{"UserMessage":"3","InstanceCount":1},{"UserMessage":"4","InstanceCount":1},{"UserMessage":"5","InstanceCount":1},{"UserMessage":"6","InstanceCount":1},{"UserMessage":"7","InstanceCount":1},{"UserMessage":"8","InstanceCount":1},{"UserMessage":"9","InstanceCount":1},{"UserMessage":"10","InstanceCount":1},{"UserMessage":"how a you?","InstanceCount":1},{"UserMessage":"how you","InstanceCount":1},{"UserMessage":"who wrote invisible man","InstanceCount":1},{"UserMessage":"sho rooms","InstanceCount":1},{"UserMessage":"show rooms","InstanceCount":5},{"UserMessage":"lst rum","InstanceCount":1},{"UserMessage":"cancel ","InstanceCount":1},{"UserMessage":"cancel booking for koln from 1","InstanceCount":1},{"UserMessage":"show","InstanceCount":1},{"UserMessage":"room","InstanceCount":1},{"UserMessage":"show all bookings","InstanceCount":1},{"UserMessage":"am i mad","InstanceCount":1},{"UserMessage":"have i gone mad","InstanceCount":2},{"UserMessage":"have i gone mad?","InstanceCount":1},{"UserMessage":"book rum","InstanceCount":1},{"UserMessage":"try","InstanceCount":1},{"UserMessage":"my","InstanceCount":1},{"UserMessage":"book amsterdam from 1 2","InstanceCount":1},{"UserMessage":"book amsterdam from 1 - 2","InstanceCount":1},{"UserMessage":"something","InstanceCount":1},{"UserMessage":"Im fine","InstanceCount":1},{"UserMessage":"sdf","InstanceCount":2},{"UserMessage":"zxc","InstanceCount":1},{"UserMessage":"book random from 1am","InstanceCount":1},{"UserMessage":"List rooms","InstanceCount":1},{"UserMessage":"alice","InstanceCount":1},{"UserMessage":"show booking","InstanceCount":1},{"UserMessage":"yes","InstanceCount":1},{"UserMessage":"tes","InstanceCount":1},{"UserMessage":"?","InstanceCount":1}] | ||
[{"UserMessage":"test\n","InstanceCount":2},{"UserMessage":"tes","InstanceCount":1},{"UserMessage":"ho r u","InstanceCount":1},{"UserMessage":"how r u","InstanceCount":1},{"UserMessage":"h r u","InstanceCount":1},{"UserMessage":"book \ntest","InstanceCount":1},{"UserMessage":"a\nb\nc\n","InstanceCount":1},{"UserMessage":"enter","InstanceCount":1},{"UserMessage":"entre\nenter","InstanceCount":1}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"RoomName":"Utrecht","BookedFromUtc":"2019-06-24T19:30:00Z","BookedToUtc":"2019-06-24T20:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-25T00:50:50.3554925+05:30"},{"RoomName":"Hamberg","BookedFromUtc":"2019-06-24T19:30:00Z","BookedToUtc":"2019-06-24T20:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-25T00:50:56.9470091+05:30"},{"RoomName":"Eindhoven","BookedFromUtc":"2019-06-24T19:30:00Z","BookedToUtc":"2019-06-24T20:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-25T00:51:00.0259062+05:30"},{"RoomName":"Koln","BookedFromUtc":"2019-06-24T19:30:00Z","BookedToUtc":"2019-06-24T20:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-25T00:53:34.1576857+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-06-25T18:00:00Z","BookedToUtc":"2019-06-25T18:14:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-25T22:20:07.6721796+05:30"},{"RoomName":"Eindhoven","BookedFromUtc":"2019-06-25T19:30:00Z","BookedToUtc":"2019-06-25T20:29:59.999Z","BookedBy":"Vinod","BookedFor":"meeting","BookedOnUtc":"2019-06-26T00:17:33.9101279+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-06-29T12:30:00Z","BookedToUtc":"2019-06-29T13:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-29T16:10:27.6405683+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-06-29T13:30:00Z","BookedToUtc":"2019-06-29T14:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-29T16:11:26.9658733+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-06-29T14:30:00Z","BookedToUtc":"2019-06-29T15:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-29T16:13:16.5651628+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-08-01T08:00:00Z","BookedToUtc":"2019-08-01T08:29:59.999Z","BookedBy":"Vinod","BookedFor":"meeting","BookedOnUtc":"2019-07-13T22:33:11.3796367+05:30"},{"RoomName":"Amsterdam","BookedFromUtc":"2019-07-24T17:00:00Z","BookedToUtc":"2019-07-24T17:19:59.999Z","BookedBy":"Marco","BookedFor":"meeting","BookedOnUtc":"2019-07-24T22:23:57.3921834+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-07-28T08:00:00Z","BookedToUtc":"2019-07-28T08:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-07-28T01:11:51.8623266+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-07-28T08:30:00Z","BookedToUtc":"2019-07-28T09:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-07-28T01:12:37.7513864+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-07-28T09:30:00Z","BookedToUtc":"2019-07-28T10:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-07-28T01:12:50.2641775+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2020-04-01T08:00:00Z","BookedToUtc":"2020-04-01T08:29:59.999Z","BookedBy":"Vinod","BookedFor":"meeting","BookedOnUtc":"2019-07-29T00:18:19.3194253+05:30"}] | ||
[{"RoomName":"Utrecht","BookedFromUtc":"2019-06-24T19:30:00Z","BookedToUtc":"2019-06-24T20:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-25T00:50:50.3554925+05:30"},{"RoomName":"Hamberg","BookedFromUtc":"2019-06-24T19:30:00Z","BookedToUtc":"2019-06-24T20:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-25T00:50:56.9470091+05:30"},{"RoomName":"Eindhoven","BookedFromUtc":"2019-06-24T19:30:00Z","BookedToUtc":"2019-06-24T20:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-25T00:51:00.0259062+05:30"},{"RoomName":"Koln","BookedFromUtc":"2019-06-24T19:30:00Z","BookedToUtc":"2019-06-24T20:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-25T00:53:34.1576857+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-06-25T18:00:00Z","BookedToUtc":"2019-06-25T18:14:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-25T22:20:07.6721796+05:30"},{"RoomName":"Eindhoven","BookedFromUtc":"2019-06-25T19:30:00Z","BookedToUtc":"2019-06-25T20:29:59.999Z","BookedBy":"Vinod","BookedFor":"meeting","BookedOnUtc":"2019-06-26T00:17:33.9101279+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-06-29T12:30:00Z","BookedToUtc":"2019-06-29T13:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-29T16:10:27.6405683+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-06-29T13:30:00Z","BookedToUtc":"2019-06-29T14:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-29T16:11:26.9658733+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-06-29T14:30:00Z","BookedToUtc":"2019-06-29T15:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-06-29T16:13:16.5651628+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-08-01T08:00:00Z","BookedToUtc":"2019-08-01T08:29:59.999Z","BookedBy":"Vinod","BookedFor":"meeting","BookedOnUtc":"2019-07-13T22:33:11.3796367+05:30"},{"RoomName":"Amsterdam","BookedFromUtc":"2019-07-24T17:00:00Z","BookedToUtc":"2019-07-24T17:19:59.999Z","BookedBy":"Marco","BookedFor":"meeting","BookedOnUtc":"2019-07-24T22:23:57.3921834+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-07-28T08:00:00Z","BookedToUtc":"2019-07-28T08:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-07-28T01:11:51.8623266+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-07-28T08:30:00Z","BookedToUtc":"2019-07-28T09:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-07-28T01:12:37.7513864+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2019-07-28T09:30:00Z","BookedToUtc":"2019-07-28T10:29:59.999Z","BookedBy":"Vinod","BookedFor":null,"BookedOnUtc":"2019-07-28T01:12:50.2641775+05:30"},{"RoomName":"amsterdam","BookedFromUtc":"2020-04-01T08:00:00Z","BookedToUtc":"2020-04-01T08:29:59.999Z","BookedBy":"Vinod","BookedFor":"meeting","BookedOnUtc":"2019-07-29T00:18:19.3194253+05:30"},{"RoomName":"Training room","BookedFromUtc":"2019-08-02T04:30:00Z","BookedToUtc":"2019-08-02T05:29:59.999Z","BookedBy":"Vinod","BookedFor":"meeting","BookedOnUtc":"2019-08-01T23:37:05.4517359+05:30"},{"RoomName":"training room","BookedFromUtc":"2019-08-02T08:00:00Z","BookedToUtc":"2019-08-02T08:29:59.999Z","BookedBy":"Vinod","BookedFor":"meeting on code quality","BookedOnUtc":"2019-08-01T23:51:04.7185742+05:30"}] |