Advertisement
Guest User

Untitled

a guest
Jul 13th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. - (IBAction)saveCustomer:(id)sender {
  2. @try {
  3. [self.view endEditing:YES];
  4.  
  5. // Cannot save if customer is pending
  6. if ([self.service isWaitingForApproval]) {
  7. APAlert(WARNING_TITLE, NSLocalizedString(@"message.waiting-approval", nil));
  8. return;
  9. }
  10.  
  11. // Check required field
  12. NSString *incompleteRequiredField = [self.service checkRequiredFields];
  13. if (incompleteRequiredField) {
  14. NSString *message = [NSString localizedStringWithFormat:NSLocalizedString(@"message.required field %@", nil), NSLocalizedString(incompleteRequiredField, nil)];
  15. APAlert(WARNING_TITLE, message);
  16. return;
  17. }
  18.  
  19. if(![self.service isDistributorOrWholesalerInTW]) {
  20. incompleteRequiredField = [self checkRequireCellOTM];
  21. if(incompleteRequiredField) {
  22. NSString *message = [NSString localizedStringWithFormat:NSLocalizedString(@"message.required otm %@", nil), NSLocalizedString(incompleteRequiredField, nil)];
  23. APAlert(WARNING_TITLE, message);
  24. return;
  25. }
  26. }
  27.  
  28. Country_Identifier countryID = (Country_Identifier)[self.service.customer.country_id integerValue];
  29. if (countryID == Country_Taiwan || countryID == Country_Thailand) {
  30. if (![self.service isHasContact]) {
  31. APAlert(WARNING_TITLE, ALERT_CONFRIM_HAVE_CONTACT);
  32. return;
  33. }
  34. }
  35. [[SomeManager alertViewManager] showAlertWithTitle:SAVING_TITLE
  36. message:SAVE_CUSTOMER_CONFIRM
  37. target:self
  38. actionView:nil
  39. cancelButtonTitle:YES_BUTTON_TITLE
  40. otherButtonTitles:NO_BUTTON_TITLE
  41. andTag:AlertViewTag_Save];
  42. }
  43. @catch(NSException *exception) {
  44. [self sendException:exception];
  45. }
  46. }
  47.  
  48. - (NSString*)validateServiceReadiness:(NSString*)requiredCellOTM {
  49. // Cannot save if customer is pending
  50. if ([self isWaitingForApproval]) {
  51. return NSLocalizedString(@"message.waiting-approval", nil);
  52. }
  53.  
  54. // Check required field
  55. NSString *incompleteRequiredField = [self checkRequiredFields];
  56. if (incompleteRequiredField) {
  57. NSString *message = [NSString localizedStringWithFormat:NSLocalizedString(@"message.required field %@", nil), NSLocalizedString(incompleteRequiredField, nil)];
  58. return message;
  59. }
  60.  
  61. if(![self isDistributorOrWholesalerInTW]) {
  62. incompleteRequiredField = requiredCellOTM;
  63. if(incompleteRequiredField) {
  64. NSString *message = [NSString localizedStringWithFormat:NSLocalizedString(@"message.required otm %@", nil), NSLocalizedString(incompleteRequiredField, nil)];
  65. return message;
  66. }
  67. }
  68.  
  69. Country_Identifier countryID = (Country_Identifier)[self.customer.country_id integerValue];
  70. if (countryID == Country_Taiwan || countryID == Country_Thailand) {
  71. if (![self isHasContact]) {
  72. return ALERT_CONFRIM_HAVE_CONTACT;
  73. }
  74. }
  75. }
  76.  
  77. - (IBAction)saveCustomer:(id)sender {
  78. @try {
  79. [self.view endEditing:YES];
  80.  
  81. NSString *serviceReadinessMessage = [self.service validateServiceReadiness:[self checkRequireCellOTM]];
  82. if (serviceReadynessMessage != nil) {
  83. APAlert(WARNING_TITLE, serviceReadinessMessage);
  84. return;
  85. }
  86. [[SomeManager alertViewManager] showAlertWithTitle:SAVING_TITLE
  87. message:SAVE_CUSTOMER_CONFIRM
  88. target:self
  89. actionView:nil
  90. cancelButtonTitle:YES_BUTTON_TITLE
  91. otherButtonTitles:NO_BUTTON_TITLE
  92. andTag:AlertViewTag_Save];
  93. }
  94. @catch(NSException *exception) {
  95. [self sendException:exception];
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement