Guest User

Untitled

a guest
Jun 29th, 2018
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. App_BaseController {
  2.  
  3. public OnlineApplicationStatusController() {
  4. public Application__c application {get; set;}
  5. public Contact contact {get; set;}
  6.  
  7. User currentUser = [SELECT contactId FROM User WHERE Id =
  8. :UserInfo.getUserId()];
  9. System.debug(System.LoggingLevel.ERROR, 'Current user' + currentUser);
  10.  
  11. Id,FirstName,MiddleName,LastName,Name,Birthdate,hed__Gender__c,
  12. HomePhone
  13.  
  14.  
  15. FROM Contact
  16. WHERE Id = :currentUser.ContactId
  17. LIMIT 1
  18. ];
  19.  
  20. System.debug(System.LoggingLevel.ERROR, 'contact information: ' + contact );
  21.  
  22. SELECT Id, Contact__c,Application_Status__c
  23.  
  24. FROM Application__c
  25. WHERE Contact__c =: currentUser.contactId
  26. LIMIT 1];
  27.  
  28. System.debug(System.LoggingLevel.ERROR, 'application details ' + application );
  29.  
  30. //Here is the problem
  31. update application;
  32. return pr;
  33.  
  34.  
  35. }
  36.  
  37. Profile ownerProfile = [select id from profile where name='System Administrator'];
  38. UserRole ownerRole = [SELECT id from UserRole where name = 'Admin'];
  39. User ALOProfile= [SELECT id,ProfileId, name, phone, email from User where name = 'ALO Test02'];
  40.  
  41.  
  42. User ownerUser = new User();
  43. ownerUser.firstname ='James';
  44. ownerUser.lastname ='Dobb';
  45. ownerUser.email ='thisisatesasdfasdftemail@asdfasdfasdfnigknekncih.com';
  46. ownerUser.username ='thisisasdfasdfatestemail@asdfasdfasdfnigknekncih.com';
  47. ownerUser.alias ='asdddsdf';
  48. ownerUser.TimeZoneSidKey ='GMT';
  49. ownerUser.LocaleSidKey ='en_US';
  50. ownerUser.emailencodingkey ='UTF-8';
  51. ownerUser.languagelocalekey ='en_US';
  52. ownerUser.ProfileId = ownerProfile.Id;
  53. ownerUser.userroleid = ownerRole.Id;
  54. insert ownerUser;
  55. system.debug('owner user' + ownerUser);
  56.  
  57.  
  58. User counselor = new User();
  59. counselor.firstName='Counselor';
  60. counselor.lastname ='01';
  61. counselor.phone='7864513421';
  62. counselor.fax='12345';
  63. counselor.email='counselor01@gmail.com';
  64. counselor.username ='counselor01@gmail.com';
  65. counselor.alias ='abcdef';
  66. counselor.TimeZoneSidKey ='GMT';
  67. counselor.LocaleSidKey ='en_US';
  68. counselor.emailencodingkey ='UTF-8';
  69. counselor.languagelocalekey ='en_US';
  70. counselor.ProfileId = ownerProfile.Id;
  71.  
  72.  
  73. User liasion = new User();
  74. liasion.firstName='ALO';
  75. liasion.lastname ='Test01';
  76. liasion.phone='3454513421';
  77. liasion.fax='12345';
  78. liasion.email='abc@gmail.com';
  79. liasion.username ='alo.test01t@gmail.com';
  80. liasion.alias ='ghijkl';
  81. liasion.TimeZoneSidKey ='GMT';
  82. liasion.LocaleSidKey ='en_US';
  83. liasion.emailencodingkey ='UTF-8';
  84. liasion.languagelocalekey ='en_US';
  85. liasion.ProfileId = ALOProfile.ProfileId;
  86. liasion.ALO__C='100018';
  87.  
  88.  
  89. system.runas(ownerUser){
  90.  
  91. insert counselor;
  92. system.debug('counselor' + counselor);
  93.  
  94. }
  95.  
  96.  
  97. system.runas(ownerUser){
  98.  
  99. insert liasion;
  100. system.debug('liasion' + liasion);
  101.  
  102. }
  103.  
  104.  
  105. Contact contact = new Contact();
  106. contact.firstName = 'Scott';
  107. contact.lastName = 'Petey';
  108. contact.email = 'test@test.com';
  109. contact.Owner= counselor;
  110. //contact.ALO__c= ALOProfile.Id;
  111. contact.ALO__c=liasion.Id;
  112.  
  113.  
  114.  
  115.  
  116. system.runas(ownerUser){
  117. insert contact;
  118. system.debug('contact' + contact);
  119. }
  120.  
  121. Application__c application= new Application__c();
  122. application.Contact__c = contact.Id;
  123.  
  124.  
  125.  
  126.  
  127. system.runas(ownerUser){
  128.  
  129. insert application;
  130. system.debug('application' + application);
  131. }
  132.  
  133.  
  134.  
  135.  
  136. Profile pr = [select id from profile where name='Community Login User'];
  137. User u = new User();
  138. u.firstname ='James';
  139. u.lastname ='Dobb';
  140. u.email ='thisisatestemail@asdfasdfasdfnigknekncih.com';
  141. u.username ='thisisatestemail@asdfasdfasdfnigknekncih.com';
  142. u.alias ='asdfasdf';
  143. u.TimeZoneSidKey ='GMT';
  144. u.LocaleSidKey ='en_US';
  145. u.emailencodingkey ='UTF-8';
  146. u.languagelocalekey ='en_US';
  147. u.ProfileId = pr.Id;
  148. u.contactId =contact.id;
  149. insert u;
  150.  
  151. system.debug('community user' + u);
  152.  
  153. system.runAs(u){
  154.  
  155. OnlineApplicationStatusController controllerClass = new
  156. OnlineApplicationStatusController();
  157. ApexPages.currentPage().getParameters().put('appId', application.Id);
  158. controllerClass.withdrawapplication();
  159.  
  160.  
  161.  
  162.  
  163. }
Add Comment
Please, Sign In to add comment