/// <summary> /// Method to control the requests of landing from the rockets /// </summary> /// <param name="rocketLandingPosition">x,y pair to check</param> /// <returns type=string>ok for landing - when there is no problem to land /// out of the platform - request is outside of landing platform /// clash - the previous rocket check for the same position or the /// checked position is within the safety area of the previous /// rocket ///</returns> public string LandingRequest(Coordinate rocketLandingPosition) { string response = string.Empty; if (PreviousRocketLandingPosition != null && AreasService.IsCoordinateInside(PreviousRocketLandingPosition, rocketLandingPosition)) { response = Response.CLASH; } else if (AreasService.IsCoordinateInside(LandingPlatform, rocketLandingPosition)) { response = Response.OK_FOR_LANDING; } else { response = Response.OUT_OF_PLATFORM; } // we save the request of landing PreviousRocketLandingPosition = AreasService.CreateSafetyArea(rocketLandingPosition); return(response); }
/// <summary> /// Fetches the price history of a material /// </summary> /// <param name="fetchMaterialFinishPriceHistoryDTO">FetchMaterialPriceHistoryDTO with the information about the fetch</param> /// <returns>GetAllMaterialPriceHistoryModelView with the material price history fetch information</returns> public GetAllMaterialPriceHistoryModelView fetchMaterialPriceHistory(FetchMaterialPriceHistoryDTO fetchMaterialPriceHistoryDTO, IHttpClientFactory clientFactory) { IEnumerable <MaterialPriceTableEntry> materialPriceHistory = PersistenceContext.repositories().createMaterialPriceTableRepository().fetchMaterialPriceHistory(fetchMaterialPriceHistoryDTO); FetchEnsurance.ensureMaterialPriceHistoryFetchWasSuccessful(materialPriceHistory); if (fetchMaterialPriceHistoryDTO.currency != null && fetchMaterialPriceHistoryDTO.area != null) { CurrenciesService.checkCurrencySupport(fetchMaterialPriceHistoryDTO.currency); AreasService.checkAreaSupport(fetchMaterialPriceHistoryDTO.area); foreach (MaterialPriceTableEntry materialPriceTableEntry in materialPriceHistory) { Task <double> convertedValueTask = new CurrencyPerAreaConversionService(clientFactory) .convertDefaultCurrencyPerAreaToCurrencyPerArea(materialPriceTableEntry.price.value, fetchMaterialPriceHistoryDTO.currency, fetchMaterialPriceHistoryDTO.area); convertedValueTask.Wait(); materialPriceTableEntry.price.value = convertedValueTask.Result; } return(PriceTableModelViewService.fromMaterialCollection(materialPriceHistory, fetchMaterialPriceHistoryDTO.currency, fetchMaterialPriceHistoryDTO.area)); } return(PriceTableModelViewService.fromMaterialCollection(materialPriceHistory, CurrencyPerAreaConversionService.getBaseCurrency(), CurrencyPerAreaConversionService.getBaseArea())); }
/// <summary> /// Отображение/скрытие соответсвующих полей окна, загрузка списов из БД (если нужно) /// </summary> private void AdditionalInitializeComponent() { const Visibility show = Visibility.Visible; const Visibility hide = Visibility.Collapsed; // Отображение/скрытие полей PeriodWrapperGrid.Visibility = _isPeriod ? show : hide; MonthOrYearWrapperGrid.Visibility = _isMonthOrYear ? show : hide; DateWrapperGrid.Visibility = _isDate ? show : hide; DatePeriodWrapperGrid.Visibility = _isDatePeriod ? show : hide; KoefTWrapperGrid.Visibility = _isKoefT ? show : hide; KoefZWrapperGrid.Visibility = _isKoefZ ? show : hide; CehWrapperGrid.Visibility = _isWorkGuild ? show : hide; AreaWrapperGrid.Visibility = _isArea ? show : hide; WorkGuildSpecifiedOrAllWrapperGrid.Visibility = _isWorkGuildSpecifiedOrAll ? show : hide; ProductWrapperGrid.Visibility = _isProduct ? show : hide; DetailWrapperGrid.Visibility = _isDetail ? show : hide; ProductSpecifiedOrAllWrapperGrid.Visibility = _isProductSpecifiedOrAll ? show : hide; AssemblyUnitWrapperGrid.Visibility = _isAssemblyUnit ? show : hide; MonthYearWrapperGrid.Visibility = _isMonthYear ? show : hide; TimeFundWrapperGrid.Visibility = _isTimeFund ? show : hide; ProcentageOfLossTimeWrapperGrid.Visibility = _isProcentageOfLossTime ? show : hide; ProcentageOfPerformanceStandartsWrapperGrid.Visibility = _isProcentageOfPerformanceStandarts ? show : hide; AreaSpecifiedOrAllWrapperGrid.Visibility = _isAreaSpecifiedOrAll ? show : hide; MessageLabel.Content = _hintMessage; // Если вводится [Дата] - значение по-умолчанию сегодняшняя if (_isDate) { DatePicker.SelectedDate = DateTime.Today; } if (_isWorkGuild) { try { WorkGuildsComboBox.ItemsSource = WorkGuildsService.GetAll(); } catch (StorageException ex) { Common.ShowDetailExceptionMessage(ex); } } // Если вводится [Изделие] - загрузка списка из БД и заполнение Textbox if (_isProductSpecifiedOrAll) { try { _searchProductStorage = ProductsService.GetProducts(); SearchProductDataGrid.ItemsSource = _searchProductStorage; } catch (StorageException ex) { Common.ShowDetailExceptionMessage(ex); return; } ProductAllRadioButton.IsChecked = true; } // Если вводится [Цех] - загрузка списка из БД и заполнение ComboBox if (_isWorkGuildSpecifiedOrAll) { try { WorkguildSpecifiedComboBox.ItemsSource = WorkGuildsService.GetAll(); } catch (StorageException ex) { Common.ShowDetailExceptionMessage(ex); return; } WorkguildAllRadioButton.IsChecked = true; } // Если вводится [Участок] - загрузка списка из БД и заполнение ComboBox if (_isAreaSpecifiedOrAll) { try { AreaSpecifiedComboBox.ItemsSource = AreasService.GetAll(); } catch (StorageException ex) { Common.ShowDetailExceptionMessage(ex); return; } AreaAllRadioButton.IsChecked = true; } if (_isArea) { try { AreaComboBox.ItemsSource = AreasService.GetAll(); } catch (StorageException ex) { Common.ShowDetailExceptionMessage(ex); } } // Если вводится [Изделие] - загрузка списка из БД и заполнение Textbox if (_isProduct) { try { _searchProductStorage = ProductsService.GetProducts(); SearchProductDataGrid.ItemsSource = _searchProductStorage; } catch (StorageException ex) { Common.ShowDetailExceptionMessage(ex); } } // Если вводится [Деталь] - загрузка списка из БД и заполнение Textbox if (_isDetail) { try { _searchDetailStorage = DetailsService.GetAll(); SearchDetailDataGrid.ItemsSource = _searchDetailStorage; } catch (StorageException ex) { Common.ShowDetailExceptionMessage(ex); } } // Если вводится [Сборочноя еденица] - загрузка списка из БД и заполнение Textbox if (_isAssemblyUnit) { try { _searchProductStorage = ProductsService.GetAssemblyUnits(); SearchAssemblyUnitDataGrid.ItemsSource = _searchProductStorage; } catch (StorageException ex) { Common.ShowDetailExceptionMessage(ex); } } // Если вводится [Месяц/Год] - получение Dictionary месяцев и заполнение ComboBox, год текущий // ReSharper disable once InvertIf if (_isMonthYear) { const int monthOffset = 1; var today = DateTime.Today; MonthComboBox.ItemsSource = Common.MonthsFullNames(); MonthComboBox.SelectedIndex = today.Month - monthOffset; YearIntegerUpDown.Value = today.Year; } ConfirmButton.Focus(); }
public AreasController() { areasService = new AreasService(); groupService = new GroupService(); userProfileService = new UserProfileService(); }