public async Task <IActionResult> Add(Module_PermissionView module_permission) { ResponseHelper objHelper = new ResponseHelper(); if (!ModelState.IsValid) { objHelper.Status = StatusCodes.Status424FailedDependency; objHelper.Message = ModelException.Errors(ModelState); return(BadRequest(objHelper)); } try { if (Module_PermissionRepo.Exists(module_permission)) { objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Data already available"; return(Ok(objHelper)); } await Module_PermissionRepo.Insert(module_permission); objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Saved Successfully"; objHelper.Data = module_permission; return(Ok(objHelper)); } catch (Exception ex) { objHelper.Status = StatusCodes.Status500InternalServerError; objHelper.Message = ex.Message; return(StatusCode(StatusCodes.Status500InternalServerError, objHelper)); } }
#pragma warning disable XS0001 // Find usages of mono todo items // Generate structured data for a dotnet exception. static ModelException GenerateModelException(Exception exception, bool structuredFrames) { var modelException = new ModelException { Type = exception.GetType().FullName, Message = exception.Message, StackTrace = exception.StackTrace, Frames = structuredFrames ? GenerateModelStackFrames(new StackTrace(exception, true)) : null, WrapperSdkName = WrapperSdk.Name }; var aggregateException = exception as AggregateException; if (aggregateException?.InnerExceptions != null) { modelException.InnerExceptions = new List <ModelException>(); foreach (var innerException in aggregateException.InnerExceptions) { modelException.InnerExceptions.Add(GenerateModelException(innerException, structuredFrames)); } } else if (exception.InnerException != null) { modelException.InnerExceptions = new List <ModelException> { GenerateModelException(exception.InnerException, structuredFrames) }; } return(modelException); }
public async Task <IActionResult> UpdateStatus(int id, short isActive) { ResponseHelper objHelper = new ResponseHelper(); if (!ModelState.IsValid) { objHelper.Status = StatusCodes.Status424FailedDependency; objHelper.Message = ModelException.Errors(ModelState); return(BadRequest(objHelper)); } try { await designationRepository.ToogleStatus(id, isActive); objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Saved Successfully"; return(Ok(objHelper)); } catch (Exception ex) { objHelper.Status = StatusCodes.Status500InternalServerError; objHelper.Message = ex.Message; return(StatusCode(StatusCodes.Status500InternalServerError, objHelper)); } }
public PatientViewModel GetPatientDetails(int patientId, List <PatientMedicalAidDependancyViewModel> patientMedicalAidDepandancies) { PatientDetailResponse response = _PhekoServiceClient.GetPatientDetails(patientId); ServiceResponse <PatientViewModel> serviceResponse = new ServiceResponse <PatientViewModel>(); serviceResponse.IsModelValid = response.HasErrors; if (response.HasErrors) { ModelException modelException = new ModelException(); response.FieldErrors.ToList <FieldError>().ForEach(item => modelException.ModelErrors.Add(new ModelError() { FieldName = item.FieldName, Message = item.ErrorMessage })); throw modelException; } PatientViewModel model = _PatientViewModelMapper.MapToPatientViewModel(response.Patient); if (response.PatientMedicalAidDependancies != null && response.PatientMedicalAidDependancies.Count() > 0) { response.PatientMedicalAidDependancies.ToList().ForEach(item => patientMedicalAidDepandancies.Add(_PatientMedicalAidDependancyViewModelMapper.MapToPatientMedicalAidDependancyViewModel(item))); } return(model); }
//[TypeFilter(typeof(ActionFilters.RolesValidate), Arguments = new object[] { "Department", EnumPermission.Add })] public async Task <IActionResult> Add(DepartmentView department) { ResponseHelper objHelper = new ResponseHelper(); if (!ModelState.IsValid) { objHelper.Status = StatusCodes.Status424FailedDependency; objHelper.Message = ModelException.Errors(ModelState); return(BadRequest(objHelper)); } try { if (departmentRepository.Exists(department)) { objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Data already available"; return(Ok(objHelper)); } await departmentRepository.Insert(department); objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Saved Successfully"; objHelper.Data = department; return(Ok(objHelper)); } catch (Exception ex) { objHelper.Status = StatusCodes.Status500InternalServerError; objHelper.Message = ex.Message; return(StatusCode(StatusCodes.Status500InternalServerError, objHelper)); } }
public async Task <IActionResult> Edit(Email_ConfigView Email_Config) { ResponseHelper objHelper = new ResponseHelper(); if (!ModelState.IsValid) { objHelper.Status = StatusCodes.Status424FailedDependency; objHelper.Message = ModelException.Errors(ModelState); return(BadRequest(objHelper)); } try { if (Email_ConRepo.Exists(Email_Config)) { objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Data already available"; return(Ok(objHelper)); } await Email_ConRepo.Update(Email_Config); objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Saved Successfully"; return(Ok(objHelper)); } catch (Exception ex) { objHelper.Status = StatusCodes.Status500InternalServerError; objHelper.Message = ex.Message; return(StatusCode(StatusCodes.Status500InternalServerError, objHelper)); } }
private bool TryLoadGame(bool showSuccess) { string oldFileName = ViewModel.FileName, oldFileTitle = ViewModel.FileTitle; try { if (!GetFileNameToViewModel(false, false)) { return(false); } ModelException.TryThrow <GameController.T>(Controller.TryLoadGame(ViewModel.FileName)); if (showSuccess) { MessageBox.Show(this, "Hra byla načtena.", "Informace", MessageBoxButton.OK, MessageBoxImage.Information); } return(true); } catch (Exception exc) { ViewModel.SetFileName(oldFileName, oldFileTitle); MessageBox.Show(this, ViewModelCommon.ConvertExceptionToShortString(exc), "Chyba", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } }
//[ServiceFilter(typeof(ActionFilters.TokenVerify))] //[TypeFilter(typeof(ActionFilters.RolesValidate), Arguments = new object[] { "User", EnumPermission.Edit })] public IActionResult Edit(UserView user) { ResponseHelper objResHelper = new ResponseHelper(); if (!ModelState.IsValid) { objResHelper.Status = StatusCodes.Status424FailedDependency;; objResHelper.Message = ModelException.Errors(ModelState); return(BadRequest(objResHelper)); } try { if (userRepository.UserExist(user)) { objResHelper.Status = StatusCodes.Status208AlreadyReported; objResHelper.Message = "Data already available"; return(Ok(objResHelper)); } userRepository.UpdateUser(user); objResHelper.Data = user; objResHelper.Status = StatusCodes.Status200OK; objResHelper.Message = "Saved Successfully"; return(Ok(objResHelper)); } catch (Exception ex) { objResHelper.Status = StatusCodes.Status500InternalServerError; objResHelper.Message = ex.Message; return(StatusCode(StatusCodes.Status500InternalServerError, objResHelper)); } }
public MainWindowViewModel() { if (Model == null) { Model = ModelException.TryThrow <GameModel.T>(GameModel.tryCreate()); } InitModel(); }
public void Constructor_1_OK() { // Arrange: // Act: var ex1 = new ModelException("test"); // Assert: }
public void Constructor_0_OK() { // Arrange: // Act: var ex0 = new ModelException(); // Assert: }
public BuildException(HttpContext context, System.Exception err, string request) { _context = context; _err = err; _mExeption = BuildExeption(err, request); if (_context.User.Identity.IsAuthenticated) { _mExeption.Identity = _context.User.Identity; } }
private static Task HandleModelExceptionAsync(HttpContext context, ModelException exception) { context.Response.ContentType = "application/json"; context.Response.StatusCode = (int)HttpStatusCode.NotAcceptable; return(context.Response.WriteAsync(new ErrorDetails() { StatusCode = context.Response.StatusCode, Message = exception.Message }.ToString())); }
public void Constructor_2_OK() { // Arrange: // Act: var ex2 = new ModelException( "test", new Exception()); // Assert: }
public ReplayWindow(Latrunculi.Controller.ReplayController.T controller, ReplayWindowViewModel viewModel) { DataContext = viewModel; Controller = controller; InitializeComponent(); ViewModel.Model.PositionChanged += Model_PositionChanged; Dispatcher.BeginInvoke(new Action(() => { ModelException.TryThrow <ReplayController.T>(Controller.tryGoToPosition(0)); }), System.Windows.Threading.DispatcherPriority.Background); }
private void Redo_Executed(object sender, ExecutedRoutedEventArgs e) { if (ViewModel.Position < ViewModel.NumberOfMoves) { try { ModelException.TryThrow <ReplayController.T>(Controller.tryIncPosition()); } catch (Exception exc) { ViewModel.Info = string.Format("Chyba: {0}", ViewModelCommon.ConvertExceptionToShortString(exc)); } } }
public override void OnException(HttpActionExecutedContext context) { if (context.Exception is ModelException) { ModelException exception = (ModelException)context.Exception; HttpError error = new HttpError(); error.Add("Message", "An error has occurred."); error.Add("ExceptionMessage", exception.Message); error.Add("ExceptionCode", exception.ExceptionCode); error.Add("ExceptionType", exception.Source); error.Add("StackTrace", exception.StackTrace); context.Response = context.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, error); } }
private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { e.Handled = true; try { if (!ignoreChange) { ModelException.TryThrow <ReplayController.T>(Controller.tryGoToPosition((int)e.NewValue)); } } catch (Exception exc) { ViewModel.Info = string.Format("Chyba: {0}", ViewModelCommon.ConvertExceptionToShortString(exc)); } }
private void Resume_Executed(object sender, ExecutedRoutedEventArgs e) { try { if (ViewModel.IsPaused || ViewModel.IsCreated) { ModelException.TryThrow <ReplayController.T>(Controller.tryResume()); CommandManager.InvalidateRequerySuggested(); } } catch (Exception exc) { MessageBox.Show(this, "Nelze spustit replay kvůli chybě." + Environment.NewLine + ViewModelCommon.ConvertExceptionToShortString(exc), "Chyba", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Pause_Executed(object sender, ExecutedRoutedEventArgs e) { e.Handled = true; try { if (ViewModel.IsGameRunning) { ModelException.TryThrow <GameController.T>(Controller.TryPause()); CommandManager.InvalidateRequerySuggested(); } } catch (Exception exc) { MessageBox.Show(this, "Nelze pozastavit hru kvůli chybě." + Environment.NewLine + ViewModelCommon.ConvertExceptionToShortString(exc), "Chyba", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void CancelSuggestMove_Executed(object sender, ExecutedRoutedEventArgs e) { e.Handled = true; try { if (ViewModel.IsMoveSuggestionComputing) { ModelException.TryThrow <GameController.T>(Controller.TryCancelSuggestMove()); CommandManager.InvalidateRequerySuggested(); } } catch (Exception exc) { MessageBox.Show(this, "Nepodařilo se zrušit nápovědu tahu." + Environment.NewLine + ViewModelCommon.ConvertExceptionToShortString(exc), "Chyba", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Redo_Executed(object sender, ExecutedRoutedEventArgs e) { e.Handled = true; try { if (!ViewModel.IsGameCreated && ViewModel.IsRedoStackNotEmpty) { ModelException.TryThrow <GameController.T>(Controller.TryRedo()); CommandManager.InvalidateRequerySuggested(); } } catch (Exception exc) { MessageBox.Show(this, "Tah nelze opakovat." + Environment.NewLine + ViewModelCommon.ConvertExceptionToShortString(exc), "Chyba", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void NewGame() { PlayerSettingsViewModel vm = TryShowSettings(); if (vm != null) { Controller.changePlayerSettings( new Tuple <Model.Player.Types, Model.Player.Types>(PlayerViewModel.PlayerTypeToModel(vm.WhitePlayer), PlayerViewModel.PlayerTypeToModel(vm.BlackPlayer)), new Tuple <string, string>(vm.WhitePlayer.Name, vm.BlackPlayer.Name), new Tuple <Model.Player.Levels, Model.Player.Levels>(PlayerViewModel.PlayerLevelToModel(vm.WhitePlayer), PlayerViewModel.PlayerLevelToModel(vm.BlackPlayer))); ModelException.TryThrow <GameController.T>(Controller.TryNewGame()); ModelException.TryThrow <GameController.T>(Controller.TryRun()); FocusBoard(); CommandManager.InvalidateRequerySuggested(); } }
private void SuggestMove_Executed(object sender, ExecutedRoutedEventArgs e) { e.Handled = true; try { if (ViewModel.IsGameWaitingForHumanPlayerMove && !ViewModel.IsMoveSuggestionComputing) { ViewModel.ClearBoardIndications(); ModelException.TryThrow <GameController.T>(Controller.TrySuggestMove()); CommandManager.InvalidateRequerySuggested(); } } catch (Exception exc) { MessageBox.Show(this, "Nepodařilo se napovědět tah." + Environment.NewLine + ViewModelCommon.ConvertExceptionToShortString(exc), "Chyba", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void SavePatientMedicalMonitorings(List <PatientMedicalMonitoringViewModel> patientMedicalMonitoringViewModels) { PatientMedicalMonitoringDto[] patientMedicalMonitoringDtos = patientMedicalMonitoringViewModels.Select(item => _PatientMedicalMonitoringViewModelMapper.MapToPatientMedicalMonitoringDto(item)).ToArray(); PatientMedicalMonitoringDtoResponse response = _PhekoServiceClient.SavePatientMedicalMonitorings(patientMedicalMonitoringDtos); if (response.HasErrors) { ModelException modelException = new ModelException(); response.FieldErrors.ToList <FieldError>().ForEach(item => modelException.ModelErrors.Add(new ModelError() { FieldName = item.FieldName, Message = item.ErrorMessage })); throw modelException; } }
public PatientViewModel CreatePatient(CreatePatientViewModel createPatientViewModel) { PatientDetailResponse response = _PhekoServiceClient.SavePatient(_PatientViewModelMapper.MapCreatePatientViewModelToPatientDto(createPatientViewModel)); if (response.HasErrors) { ModelException modelException = new ModelException(); response.FieldErrors.ToList <FieldError>().ForEach(item => modelException.ModelErrors.Add(new ModelError() { FieldName = item.FieldName, Message = item.ErrorMessage })); throw modelException; } return(_PatientViewModelMapper.MapToPatientViewModel(response.Patient)); }
public SecurityUserViewModel SaveUser(SecurityUserViewModel securityUserViewModel) { SecurityUserDtoResponse response = _PhekoServiceClient.SaveUser(_SecurityUserViewModelMapper.MapToSecurityUserDto(securityUserViewModel)); if (response.HasErrors) { ModelException modelException = new ModelException(); response.FieldErrors.ToList <FieldError>().ForEach(item => modelException.ModelErrors.Add(new ModelError() { FieldName = item.FieldName, Message = item.ErrorMessage })); throw modelException; } return(_SecurityUserViewModelMapper.MapToPatientAddressViewModel(response.Model)); }
public SecurityUserViewModel Login(string username, string password) { SecurityUserDtoResponse response = _PhekoServiceClient.Login(username, password); if (response.HasErrors) { ModelException modelException = new ModelException(); response.FieldErrors.ToList <FieldError>().ForEach(item => modelException.ModelErrors.Add(new ModelError() { FieldName = item.FieldName, Message = item.ErrorMessage })); throw modelException; } return(_SecurityUserViewModelMapper.MapToPatientAddressViewModel(response.Model)); }
public PatientMedicalAidDependancyViewModel SavePatientMedicalAidDependancy(PatientMedicalAidDependancyViewModel patientMedicalAidDependancyViewModel) { PatientMedicalAidDependancyDtoResponse response = _PhekoServiceClient.SavePatientMedicalAidDependancy(_PatientMedicalAidDependancyViewModelMapper.MapToPatientMedicalAidDependancyDto(patientMedicalAidDependancyViewModel)); if (response.HasErrors) { ModelException modelException = new ModelException(); response.FieldErrors.ToList <FieldError>().ForEach(item => modelException.ModelErrors.Add(new ModelError() { FieldName = item.FieldName, Message = item.ErrorMessage })); throw modelException; } return(_PatientMedicalAidDependancyViewModelMapper.MapToPatientMedicalAidDependancyViewModel(response.Model)); }
private void ClientAsyncError(object sender, AsyncErrorEventArgs e) { Dispatcher.BeginInvoke(new Action <AsyncErrorEventArgs>(args => { ModelException modelException = args.Error as ModelException; if (modelException != null) { switch (modelException.Code) { case ErrorCode.APINotSupported: ClientModel.Reset(); SelectedRoom.AddSystemMessage(Localizer.Instance.Localize(APINotSupportedKey, modelException.Message)); return; } } }), e); }