private void EditConfirmResponseHandler(MsgBxResultMessage obj) { if (obj.Result == eMessageBoxResult.Yes) { //Edit Code SelectedRole.ParentRoleId = SelectedRole.ParentRole.Id; SelectedRole.ParentRole = null; string jsonObj = JsonConvert.SerializeObject(SelectedRole); var httpContent = new StringContent(jsonObj, Encoding.UTF8, "application/json"); var response = HttpManager.Instance.Post(httpContent, APIPaths.RoleUpdate); ActionResult <OrgRoleDTO> actionResult = JsonConvert.DeserializeObject <ActionResult <OrgRoleDTO> >(response); if (actionResult.ReturnCode == eReturnCode.Success) { ShowMessageBox(eMessageBoxType.Info, Application.Current.MainWindow.Resources["txtMsgTitleSuccess"].ToString(), Application.Current.MainWindow.Resources["txtMsgTextRoleEditSuccess"].ToString()); } else { ShowMessageBox(eMessageBoxType.Error, Application.Current.MainWindow.Resources["txtMsgTitleError"].ToString(), Application.Current.MainWindow.Resources["txtMsgTextRoleEditError"].ToString()); } FetchData(); SelectedRole = new OrgRoleDTO(); SelectedRole.ParentRole = AllRoles.Where(r => r.ParentRoleId == 0).FirstOrDefault().Clone() as OrgRoleDTO; RaisePropertyChanged("SelectedRole"); } SelectedRole = new OrgRoleDTO(); SelectedRole.ParentRole = AllRoles.Where(r => r.ParentRoleId == 0).FirstOrDefault().Clone() as OrgRoleDTO; RaisePropertyChanged("SelectedRole"); Messenger.Default.Unregister <MsgBxResultMessage>(this, DeleteConfirmResponseHandler); }
private void MsgBxResultMsgHandler(MsgBxResultMessage obj) { ShowMsgBox = false; RaisePropertyChanged("ShowMsgBox"); if (obj.Type == eMessageBoxType.Confirmation) { Messenger.Default.Send <MsgBxResultMessage>(obj); } }
private void DeleteConfirmResponseHandler(MsgBxResultMessage obj) { if (obj.Result == eMessageBoxResult.Yes) { string jsonObj = JsonConvert.SerializeObject(SelectedRole); var httpContent = new StringContent(jsonObj, Encoding.UTF8, "application/json"); var response = HttpManager.Instance.Post(httpContent, APIPaths.RoleDelete); ActionResult <string> actionResult = JsonConvert.DeserializeObject <ActionResult <string> >(response); switch (actionResult.ReturnCode) { case eReturnCode.Success: ShowMessageBox(eMessageBoxType.Info, Application.Current.MainWindow.Resources["txtMsgTitleSuccess"].ToString(), Application.Current.MainWindow.Resources["txtMsgTextRoleDelSuccess"].ToString()); break; case eReturnCode.Failure: ShowMessageBox(eMessageBoxType.Error, Application.Current.MainWindow.Resources["txtMsgTitleError"].ToString(), Application.Current.MainWindow.Resources["txtMsgTextRoleDelError"].ToString()); break; case eReturnCode.EmployeeExists: ShowMessageBox(eMessageBoxType.Error, Application.Current.MainWindow.Resources["txtMsgTitleError"].ToString(), Application.Current.MainWindow.Resources["txtMsgTextRoleDelErrorEmployeeExists"].ToString()); break; case eReturnCode.SubOrdinateExists: ShowMessageBox(eMessageBoxType.Error, Application.Current.MainWindow.Resources["txtMsgTitleError"].ToString(), Application.Current.MainWindow.Resources["txtMsgTextRoleDelErrorSubOrdinatesExists"].ToString()); break; } //else //{ // ShowMessageBox(eMessageBoxType.Error, Application.Current.MainWindow.Resources["txtMsgTitleError"].ToString(), // Application.Current.MainWindow.Resources["txtMsgTextRoleDelError"].ToString()); //} FetchData(); } SelectedRole = new OrgRoleDTO(); SelectedRole.ParentRole = AllRoles.Where(r => r.ParentRoleId == 0).FirstOrDefault().Clone() as OrgRoleDTO; RaisePropertyChanged("SelectedRole"); Messenger.Default.Unregister <MsgBxResultMessage>(this, DeleteConfirmResponseHandler); }