コード例 #1
0
 public ActionResult <CompaniesVM[]> GetAll()
 {
     try
     {
         return(_cService.GetAll());
     }
     catch (Exception ex)
     {
         _logger.LogError($"Failed to get products: {ex}");
         return(BadRequest($"Failed to get products: {ex}"));
     }
 }
コード例 #2
0
        public void TestAllPositiveCompanies()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var repository =
                new EfDeletableEntityRepository <ApplicationUser>(new ApplicationDbContext(options.Options));

            var user = new ApplicationUser
            {
                Description = "test",
                Type        = UserType.Employer,
            };

            repository.AddAsync(user).GetAwaiter().GetResult();
            repository.SaveChangesAsync().GetAwaiter().GetResult();
            var company = new CompaniesService(repository);

            AutoMapperConfig.RegisterMappings(typeof(CompaniesServiceTests.MyTest).Assembly);
            var job = company.GetAll <CompaniesServiceTests.MyTest>();

            Assert.Single(company.GetAll <CompaniesServiceTests.MyTest>());
            repository.Delete(user);
            repository.SaveChangesAsync().GetAwaiter().GetResult();
        }
コード例 #3
0
        /// <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;
            WarehouseWrapperGrid.Visibility    = _isWarehouse ? show : hide;
            WorkGuildWrapperGrid.Visibility    = _isWorkGuild ? show : hide;
            DateWrapperGrid.Visibility         = _isDate ? show : hide;
            DatePeriodWrapperGrid.Visibility   = _isDatePeriod ? show : hide;
            MonthYearWrapperGrid.Visibility    = _isMonthYear ? show : hide;
            ProductWrapperGrid.Visibility      = _isProduct ? show : hide;
            CompanyWrapperGrid.Visibility      = _isCompany ? show : hide;
            TypeProductWrapperGrid.Visibility  = _isTypeProduct ? show : hide;
            FormaPaymentWrapperGrid.Visibility = _isFormaPayment ? show : hide;
            AbroadWrapperGrid.Visibility       = _isAbroad ? show : hide;

            MessageLabel.Content = _hintMessage;

            // Если вводится [Склад] - загрузка списка из БД и заполнение ComboBox
            if (_isWarehouse)
            {
                try
                {
                    WarehousesComboBox.ItemsSource = WarehousesService.GetAll();
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                    return;
                }
                WarehouseAllRadioButton.IsChecked = true;
            }

            // Если вводится [Цех] - загрузка списка из БД и заполнение ComboBox
            if (_isWorkGuild)
            {
                try
                {
                    WorkGuildsComboBox.ItemsSource = WorkGuildsService.GetAll();
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                    return;
                }
                WorkGuildAllRadioButton.IsChecked = true;
            }

            // Если вводится [Дата] - значение по-умолчанию сегодняшняя
            if (_isDate)
            {
                DatePicker.SelectedDate = DateTime.Today;
            }

            // Если вводится [Месяц/Год] - получение 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;
            }

            // Если вводится [Продукт] - загрузка списка из БД и заполнение ComboBox
            if (_isProduct)
            {
                try
                {
                    _searchProductStorage             = ProductsService.GetProductsOnlyName();
                    SearchProductDataGrid.ItemsSource = _searchProductStorage;
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                    return;
                }
            }
            // Если вводится [Компания] - загрузка списка из БД и заполнение ComboBox
            if (_isCompany)
            {
                try
                {
                    _searchCompaniesStorage             = CompaniesService.GetAll();
                    SearchCompaniesDataGrid.ItemsSource = _searchCompaniesStorage;
                }
                catch (StorageException ex)
                {
                    Common.ShowDetailExceptionMessage(ex);
                    return;
                }
            }
            //ConfirmButton.Focus();
        }