Exemplo n.º 1
0
 public void TestGetRooms()
 {
     var controller = new ExchangeController();
     var param = new BookRoomParam
     {
         LifeSize = true,
         Time = 30,
         Location = "1"
     };
     var res = controller.BookRoom(param);
 }
Exemplo n.º 2
0
        public IHttpActionResult BookRoom(BookRoomParam param)
        {
            var service = new HackExchangeService();
            HackExchangeContext context = new HackExchangeContext()
            {
                Credentials = new NetworkCredential("*****@*****.**", "%baG7cadence"),
                Endpoint = "https://outlook.office365.com/EWS/Exchange.asmx"
            };
            var rooms = service.GetRooms(context).Where(r => r.Location == "Montevideo, Uruguay" || r.Location == "Montevideo");
            RoomAvailability availability = service.GetRoomAvailability(context, "*****@*****.**", null, 60, true);

            // If there is room available
            var bookResult = new BookResult() { Booked = true, Room = rooms.First(), Start = DateTime.Now, End = DateTime.Now.AddMinutes(param.Time)};

            // If there is not, then it will find a possible slot.
            var negativeResult = new BookResult() { Booked = false, Room = rooms.First(), Start = DateTime.Now.AddMinutes(10), End = DateTime.Now.AddMinutes(param.Time) };

            return Ok(negativeResult);
        }