AirTNG.Web.Controllers.ReservationsController.Handle C# (CSharp) Method

Handle() private method

private Handle ( string from, string body ) : Task
from string
body string
return Task
        public async Task<ActionResult> Handle(string from, string body)
        {
            string smsResponse;

            try
            {
                var host = await _usersRepository.FindByPhoneNumberAsync(from);
                var reservation = await _reservationsRepository.FindFirstPendingReservationByHostAsync(host.Id);

                var smsRequest = body;
                reservation.Status =
                    smsRequest.Equals("accept", StringComparison.InvariantCultureIgnoreCase) ||
                    smsRequest.Equals("yes", StringComparison.InvariantCultureIgnoreCase)
                    ? ReservationStatus.Confirmed
                    : ReservationStatus.Rejected;

                await _reservationsRepository.UpdateAsync(reservation);
                smsResponse =
                    string.Format("You have successfully {0} the reservation", reservation.Status);
            }
            catch (Exception)
            {
                smsResponse = "Sorry, it looks like you don't have any reservations to respond to.";
            }

            return TwiML(Respond(smsResponse));
        }