- (IBAction)providerRegistration:(id)sender
{
@try
{
[self.txtClientId resignFirstResponder];
if([[self.txtEmrName notNull:self.txtEmrName] isEqualToString:@""] || [[self.txtUserName notNull:self.self.txtUserName] isEqualToString:@""] || [[self.txtPassword notNull:self.self.txtPassword] isEqualToString:@""]|| [[self.txtProvider notNull:self.self.txtProvider] isEqualToString:@""]|| [[self.txtClientId notNull:self.self.txtClientId] isEqualToString:@""])
{
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"empty" message:@"information required" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:Nil, nil];
[alert show];
return;
}
NSError *error;
NSString *url = @"http://four-developers.com/service1.svc/GetData";
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPMethod:@"POST"];
NSMutableDictionary* mapData = [[ NSMutableDictionary alloc ] init ];
//[ mapData setObject :@"MEDPRIME" forKey : @"DataSourceName"];
[ mapData setObject :self.txtEmrName.text forKey : @"aa"];
NSData *postData = [NSJSONSerialization dataWithJSONObject:mapData options:0 error:&error];
[request setHTTPBody:postData];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
// UI Updation...
}];
NSError *err = nil ;
NSDictionary *responseDict = [ NSJSONSerialization JSONObjectWithData :data options : 0 error :&err];
NSString* strResult = [responseDict objectForKey : @"ProviderRegristrationResult" ];
if([strResult isKindOfClass:[NSNull class]])
{
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"empty" message:@"Data save failed" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:Nil, nil];
[alert show];
return;
}
else if([strResult isEqualToString:@""])
{
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"empty" message:@"Data save failed" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:Nil, nil];
[alert show];
return;
}
else if([strResult isEqualToString:@"User Already Exist"])
{
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"empty" message:strResult delegate:self cancelButtonTitle:@"OK" otherButtonTitles:Nil, nil];
[alert show];
return;
}
else if([strResult isEqualToString:@"Success"])
{
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"empty" message:@"Data save successfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:Nil, nil];
[alert show];
}
}];
}
@catch (NSException *exception)
{
NSLog(@"%@",exception.description);
}
}