Exemple #1
0
        private void LoadRoleList()
        {
            var roleList = FindViewById <ListView>(Resource.Id.lstRoles);

            var listAdapter = new Adapters.RoleEditListAdapter(this, this.viewModel.Model);

            roleList.Adapter = listAdapter;

            this.Bindings.Add(Resource.Id.btnThree, "Enabled", this.viewModel.Model, "IsSavable");
        }
Exemple #2
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.viewModel.IsBusy && this.viewModel.CanEditObject)
            {
                try
                {
                    await this.viewModel.SaveRoles();

                    var roleList    = FindViewById <ListView>(Resource.Id.lstRoles);
                    var listAdapter = new Adapters.RoleEditListAdapter(this, this.viewModel.Model);
                    roleList.Adapter = listAdapter;

                    this.Bindings.RemoveAll();
                    this.Bindings.Add(Resource.Id.btnThree, "Enabled", this.viewModel.Model, "IsSavable");
                    Toast.MakeText(this, Resources.GetString(Resource.String.MessageChangesSaved), ToastLength.Short).Show();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, string.Format(this.GetString(Resource.String.Error), ex.Message), ToastLength.Long).Show();
                }
            }
        }
Exemple #3
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.viewModel.IsBusy && this.viewModel.CanEditObject)
            {
                try
                {
                    await this.viewModel.SaveRoles();

                    var roleList    = FindViewById <ListView>(Resource.Id.lstRoles);
                    var listAdapter = new Adapters.RoleEditListAdapter(this, this.viewModel.Model);
                    roleList.Adapter = listAdapter;

                    this.Bindings.RemoveAll();
                    this.Bindings.Add(Resource.Id.btnThree, "Enabled", this.viewModel.Model, "IsSavable");
                    Toast.MakeText(this, Resources.GetString(Resource.String.MessageChangesSaved), ToastLength.Short).Show();
                }
                catch (Exception ex)
                {
                    ProgressDialog.Show(this, "Error", ex.Message + Csla.DataPortal.ProxyTypeName + Csla.DataPortalClient.WcfProxy.DefaultUrl);
                }
            }
        }
Exemple #4
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            SetContentView(Resource.Layout.RoleListEdit);

            var fraStatusContent = FindViewById <FrameLayout>(Resource.Id.fraViewListEditContent);

            this.viewModel = new RoleEditList();

            this.LayoutInflater.Inflate(Resource.Layout.Menu, fraStatusContent, true);

            var btnBack = FindViewById <Button>(Resource.Id.btnFour);

            btnBack.Text       = Resources.GetString(Resource.String.ButtonBack);
            btnBack.Visibility = ViewStates.Visible;
            btnBack.Click     += btnBack_Click;

            if (this.viewModel.CanCreateObject)
            {
                var btnAddNew = FindViewById <Button>(Resource.Id.btnTwo);
                btnAddNew.Text       = Resources.GetString(Resource.String.ButtonAddNew);
                btnAddNew.Visibility = ViewStates.Visible;
                btnAddNew.Click     += btnAddNew_Click;
            }

            if (this.viewModel.CanEditObject)
            {
                var btnSave = FindViewById <Button>(Resource.Id.btnThree);
                btnSave.Text       = Resources.GetString(Resource.String.ButtonSave);
                btnSave.Visibility = ViewStates.Visible;
                btnSave.Enabled    = false;
                btnSave.Click     += btnSave_Click;
            }

            try
            {
                var parameter1 = Intent.GetByteArrayExtra(Constants.EditParameter);
                if (parameter1 != null)
                {
                    var roleEditList = (Library.Admin.RoleEditList) this.DeserializeFromParameter(parameter1);
                    this.viewModel.LoadFromExisting(roleEditList);
                }
                else
                {
                    await this.viewModel.LoadAsync();
                }

                var roleList = FindViewById <ListView>(Resource.Id.lstRoles);

                var listAdapter = new Adapters.RoleEditListAdapter(this, this.viewModel.Model);
                roleList.Adapter    = listAdapter;
                roleList.ItemClick += lstRoles_OnListItemClick;

                this.Bindings.Add(Resource.Id.btnThree, "Enabled", this.viewModel.Model, "IsSavable");
            }
            catch (Exception ex)
            {
                ProgressDialog.Show(this, "Error", ex.Message + Csla.DataPortal.ProxyTypeName);
            }
        }