//
//  AddContactViewController.m
//  HWMSDKDemo
//
//  Created by guoyongliang/gwx917154 on 2020/9/27.
//  Copyright © 2020 HuaWei. All rights reserved.
//

#import "AddContactViewController.h"

@interface AddContactViewController ()
@property (weak, nonatomic) IBOutlet UITextField *accountTextField;
@property (weak, nonatomic) IBOutlet UITextField *phoneTextField;
@property (weak, nonatomic) IBOutlet UITextField *sipTextField;
@property (weak, nonatomic) IBOutlet UITextField *thirdUserIdTextField;
@property (weak, nonatomic) IBOutlet UITextField *nameTextField;
@property (weak, nonatomic) IBOutlet UITextField *cnTextField;
@property (weak, nonatomic) IBOutlet UITextField *enTextField;
@property (weak, nonatomic) IBOutlet UITextField *extendedFieldTextField;
@property (weak, nonatomic) IBOutlet UITextField *orgIdTextField;

@end

@implementation AddContactViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (IBAction)finishClick:(id)sender {
    HWMContactSelectedModel * model = [[HWMContactSelectedModel alloc] initWithName:@"" number:@"" contactType:HWMSelectedContactTypeEnterprise];
    NSString * account = self.accountTextField.text;
    NSString * phone = self.phoneTextField.text;
    NSString * sip = self.sipTextField.text;
    NSString * thirdUserId = self.thirdUserIdTextField.text;
    if (account.length > 0) {
        model.accountId = account;
    } else if (phone.length > 0) {
        model.contactType = HWMSelectedContactTypeLocal;
        model.number = phone;
        model.type = HWMConfAttendeeTypeMobile;
    } else if (sip.length > 0) {
        model.number = sip;
    } else if (thirdUserId.length > 0) {
        model.thirdUserId = thirdUserId;
    } else {
        [UIUtil showMessage:@"请填任意一个账号"];
        return;
    }
    model.name = self.nameTextField.text;
    model.aliasCN = self.cnTextField.text;
    model.aliasEN = self.enTextField.text;
    model.extendedField = self.extendedFieldTextField.text;
    model.orgId = self.orgIdTextField.text;
    if (self.addModelResulet) {
        self.addModelResulet(model);
        [UIUtil showMessage:@"添加成功"];
    }
    
}



@end
