Guest User

Untitled

a guest
Feb 3rd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. using Karuna;
  2.  
  3. public class EventSDKSample {
  4.  
  5. void CreateEventHandler() {
  6. // Check user is logged in. If they are not we log them in
  7. // and wait for a successful response before creating the event.
  8. if (User.CurrentUser.Username == null) {
  9. API.Create(new Login() {
  10. Username = "karunademo",
  11. Password = "Karuna1!"
  12. }).AddListeners(
  13. onSuccess: (_request, _response) => { CreateEvent(); }
  14. );
  15. return;
  16. }
  17.  
  18. // otherwise we can continue without waiting for login...
  19. CreateEvent();
  20. }
  21.  
  22. void CreateEvent() {
  23. var e = new Karuna.Event() {
  24. Created = DateTime.Now,
  25. EventType = "My event type",
  26. EventValue = "My event value",
  27. // The patient still needs to be added,
  28. // but will look like so
  29. // Patient = Patient.CurrentPatient
  30. };
  31. API.Create(e);
  32. }
  33.  
  34. }
Add Comment
Please, Sign In to add comment