public async Task <ActionResult> GetPublishedTime( long start ) { var sub = GetUserId(); var query = new GetPublishedTime( sub: sub, start: start ); var r = await _db.Submit(_creds, query); var result = r.Single(); var token = _twilio.GetTwilioToken(sub.ToString(), result.HostHandle, result.Start); return(Ok( new AppointmentJson { Start = result.Start, Host = result.HostHandle, Dur = (int)((result.End - result.Start) / 60), Counterpart = result.Booked?.ToString(), Token = token })); }
public async Task <ActionResult> GetBooking( long start, string name = "n/a") { var sub = GetUserId(); var query = new GetBooking(sub, start); var result = await _db.Submit(_creds, query); var r = result.SingleOrDefault(); if (r == null) { return(NotFound()); } var token = _twilio.GetTwilioToken(name, r.Host.ToString(), r.Start); if (token == null) { _log.LogError("could not generate token with {twilioAccount}", _twilio.AccountSid); return(StatusCode(500)); } return(Ok(new AppointmentJson { Counterpart = r.Host.ToString(), Token = token, Start = r.Start, Dur = (int)(r.End - r.Start) })); }