private bool LoadMyInfo(bool bShowSuccessfulPopup = false)
        {
            //加载数据
            UserInfo_API_Get uiToGet;

            try
            {
                uiToGet = WebApiClientHelper.DoJsonRequest <UserInfo_API_Get>(GlobalData.GetResUri(string.Format("usersinfo/{0}", GlobalData.CurrentUserName)), EnuHttpMethod.Get);
            }
            catch (ClientException ex)
            {
                Commands.ShowPopupAlert.Execute(new ShowPopupAlertParam {
                    AlertMessage = ex.Message, AlertType = EnuPopupAlertType.Error
                }, this);
                return(false);
            }

            UserInfo_VM ui_vm = Mapper.Map <UserInfo_VM>(uiToGet);

            ui_vm.ModelType           = EnuModelType.View;
            gridMyInfoTab.DataContext = ui_vm;

            if (bShowSuccessfulPopup)
            {
                Commands.ShowPopupAlert.Execute(new ShowPopupAlertParam {
                    AlertMessage = "刷新我的信息成功.", AlertType = EnuPopupAlertType.Info
                }, this);
            }

            return(true);
        }
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            UserInfo_VM ui_vm = gridMyInfoTab.DataContext as UserInfo_VM;

            if (ui_vm != null)
            {
                if (ui_vm.IsModelValid())
                {
                    try
                    {
                        UserInfo_API_Put userput = Mapper.Map <UserInfo_VM, UserInfo_API_Put>(ui_vm);
                        WebApiClientHelper.DoJsonRequest <UserInfo_API_Put>(GlobalData.GetResUri(string.Format("usersinfo/{0}", ui_vm.UserName)), EnuHttpMethod.Put, objToSend: userput, tick: ui_vm.UpdateTicks);
                    }
                    catch (ClientException ex)
                    {
                        ui_vm.SetExtraError(ex.Message); //这是Popup以外的另一种异常显示方式
                        return;
                    }

                    LoadMyInfo();

                    Commands.ShowPopupAlert.Execute(new ShowPopupAlertParam {
                        AlertMessage = "修改信息成功.", AlertType = EnuPopupAlertType.Info
                    }, this);

                    Commands.GoToViewMode.Execute(null, this);
                }
            }
        }
        private void CMD_GoToViewMode(object sender, ExecutedRoutedEventArgs e)
        {
            UserInfo_VM ui_vm = gridMyInfoTab.DataContext as UserInfo_VM;

            if (ui_vm != null)
            {
                ui_vm.RecoverFromSnapshot();
                ui_vm.ModelType = EnuModelType.View;
            }
        }
        private void CMD_GoToEditMode(object sender, ExecutedRoutedEventArgs e)
        {
            UserInfo_VM ui_vm = gridMyInfoTab.DataContext as UserInfo_VM;

            if (ui_vm != null)
            {
                ui_vm.ModelType = EnuModelType.Edit;
                ui_vm.TakeSnapshot();
            }
        }