示例#1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.Title = "Employee";

            var btnSave = new UIButton(UIButtonType.Custom);

            btnSave.SetBackgroundImage(UIImage.FromBundle("Save"), UIControlState.Normal);
            btnSave.Frame          = new CGRect(0, 0, 19, 19);
            btnSave.TouchUpInside += async(sender, e) =>
            {
                BTProgressHUD.Show("Loading", -1, ProgressHUD.MaskType.Black);
                EmployeeInfo emp = new EmployeeInfo();
                emp.Name = TxtEmployeeName.Text;
                emp.DOB  = Convert.ToDateTime(TxtEmployeeDOB.Text);
                emp.Age  = Convert.ToInt32(TxtEmployeeAge.Text);
                var azureService = new AzureService();
                await azureService.InsertEmployee(emp);

                this.NavigationController.PopViewController(true);
                BTProgressHUD.Dismiss();
            };
            this.NavigationItem.SetRightBarButtonItem(null, true);
            this.NavigationItem.SetRightBarButtonItem(
                new UIBarButtonItem(btnSave), true);
        }
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var azureService = new AzureService();
            var data         = await azureService.GetEmployee(Constants.Id);

            if (data != null)
            {
                TxtEmployeeName.Text = data.Name;
                TxtEmployeeDOB.Text  = data.DOB.ToShortDateString();
                TxtEmployeeAge.Text  = Convert.ToString(data.Age);
            }

            var btnUpdate = new UIButton(UIButtonType.Custom);

            btnUpdate.SetBackgroundImage(UIImage.FromBundle("Save"), UIControlState.Normal);
            btnUpdate.Frame          = new CGRect(0, 0, 19, 19);
            btnUpdate.TouchUpInside += async(sender, e) =>
            {
                BTProgressHUD.Show("Loading", -1, ProgressHUD.MaskType.Black);
                EmployeeInfo emp = new EmployeeInfo();
                emp.Id   = data.Id;
                emp.Name = TxtEmployeeName.Text;
                emp.DOB  = Convert.ToDateTime(TxtEmployeeDOB.Text);
                emp.Age  = Convert.ToInt32(TxtEmployeeAge.Text);
                await azureService.UpdateEmployee(emp);

                this.NavigationController.PopViewController(true);
                BTProgressHUD.Dismiss();
            };
            this.NavigationItem.SetRightBarButtonItem(null, true);
            this.NavigationItem.SetRightBarButtonItem(
                new UIBarButtonItem(btnUpdate), true);
        }
示例#3
0
        public async override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, Foundation.NSIndexPath indexPath)
        {
            switch (editingStyle)
            {
            case UITableViewCellEditingStyle.Delete:
                var azureService = new AzureService();
                await azureService.DeleteEmployee(TableItems[indexPath.Row]);

                TableItems.RemoveAt(indexPath.Row);
                tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                tableView.ReloadData();
                break;
            }
        }
示例#4
0
        public async override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            BTProgressHUD.Show("Loading", -1, ProgressHUD.MaskType.Black);
            var azureService = new AzureService();
            var employees    = await azureService.GetEmployees();

            var source = new EmployeeTableSource(employees);

            source.navigationController = this.NavigationController;
            EmployeeTableView.Source    = source;
            EmployeeTableView.ReloadData();
            BTProgressHUD.Dismiss();
        }