public UpdateViewModel() { UpdataOrg = new RelayCommand(UpdateOrganization); Clean = new RelayCommand(Clear); SelectOrg = new RelayCommand(SelectForUpdate); DelOrg = new RelayCommand(DeleteOrg); updateModel = new UpdateOrgModel(); upsateRepo = new UpdateRepository(); _countryRepository = new CountryRepository(); //создаем экземпляр класса CountryRepository, который унаследован от интрефейса ICountryRepository List <CountryModel> countries = _countryRepository.GetCountries(); // создаем список объектов с типом CountryModel при помощи метода обязательного (Интрерфес) методом GetCountries из репы var countryVM = CountryMapper.CountryModelToCountryViewModel(countries); // при помощи статического метода CountryModelToCountryViewModel из класса CountryMapper приводим тип из Модели во Вью модель, чтобы наша вью модель могла работать с данными _sectionRepository = new SectionRepository(); List <SectionModel> sections = _sectionRepository.GetSections(); var sectionVM = SectionMappers.SectionModelToSectionViewModel(sections); Countries = countryVM; Section = sectionVM; Person = new UpdatePersViewModel(countryVM) { }; Organization = new UpdateOrgViewModel(countryVM, sectionVM) { CreateDateOrg = new DateTime() }; }
public ActionResult <CountryInApi> PostCountry(int continentId, [FromBody] CountryInApi countryInApi) { logger.LogInformation($"Post api/continent/{continentId}/country/ called"); try { Domain.Models.Country country = CountryMapper.CountryInMapper(continentManager, countryInApi); Domain.Models.Country countryCreated = countryManager.AddCountry(country); if (countryCreated != null) { CountryOutApi countryOut = CountryMapper.CountryOutMapper(hostUrl, countryCreated); return(CreatedAtAction(nameof(GetCountry), new { continentId = countryCreated.Continent.Id, countryId = countryCreated.Id }, countryOut)); } else { logger.LogError("Country can not be null."); return(NotFound("Country can not be null.")); } } catch (Exception ex) { logger.LogError(ex.Message); return(NotFound(ex.Message)); } }
public Country GetCountryByName([FromODataUri] string name) { var mapper = new CountryMapper(); var country = mapper.FromEntity(DbQuery().FirstOrDefault(x => x.Name.Equals(name))); return(country); }
public void Arrange() { _geocodeService = new Mock <IGeocodeService>(); _mappingService = new Mock <IMappingService>(); _vacanciesApi = new Mock <ILivevacanciesAPI>(); _standardsService = new Mock <IStandardsRepository>(); _vacanciesMapper = new VacanciesMapper(); _logger = new Mock <ILogger <VacanciesRepository> >(); _countryMapper = new CountryMapper(); _standards = new List <int>() { 1, 2 }; _standardIds = string.Join(',', _standards); _geocodeService.Setup(s => s.GetFromPostCode(It.IsAny <string>())).ReturnsAsync(coordinatesResponse); _vacanciesApi.Setup(s => s.SearchApprenticeshipVacanciesByLocationAsync(It.IsAny <double>(), It.IsAny <double>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).ReturnsAsync(GetSearchResults.MockSearchResults(coordinatesResponse)); _standardsService.Setup(s => s.GetByRoute(routeId)).ReturnsAsync(_standards); sut = new VacanciesRepository(_vacanciesApi.Object, _vacanciesMapper, _geocodeService.Object, _mappingService.Object, _logger.Object, _countryMapper, _standardsService.Object); }
public IEnumerable <Country> GetAllCountries() { var listEntityCountry = _countryService.GetAllCountries(); IEnumerable <Country> modelCountryList = CountryMapper.ConvertCountryEntityToModel(listEntityCountry); return(modelCountryList); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["CountryId"] != null) { if (!IsPostBack) { CountryEntity entity = new CountryMapper().Get(new CountryEntity() { Id = Convert.ToInt32(Request.QueryString["CountryId"]) }); if (entity != null) { TitleTextBox.Text = entity.Title; OtherInfoTextBox.Text = entity.Description; } else { Response.Redirect("List.aspx"); } } } else { Response.Redirect("List.aspx"); } }
public IActionResult Index() { var response = _bCSDirectoryService.GetCountry(); @ViewBag.Countries = CountryMapper.Convert(response); return(View()); }
public SearchWievModelOrg() { _searchRepository = new SearchRepository(); _countryRepository = new CountryRepository(); //создаем экземпляр класса CountryRepository, который унаследован от интрефейса ICountryRepository List <CountryModel> countries = _countryRepository.GetCountries(); // создаем список объектов с типом CountryModel при помощи метода обязательного (Интрерфес) методом GetCountries из репы Countries = CountryMapper.CountryModelToCountryViewModel(countries); // при помощи статического метода CountryModelToCountryViewModel из класса CountryMapper приводим тип из Модели во Вью модель, чтобы наша вью модель могла работать с данными _sectionRepository = new SectionRepository(); List <SectionModel> sections = _sectionRepository.GetSections(); Section = SectionMappers.SectionModelToSectionViewModel(sections); CreatedateOrgSTART = new DateTime(1980, 01, 01); CreatedateOrgFINAL = DateTime.Now; CheckDateOrgSTART = DateTime.Today; CheckDateOrgFINAL = DateTime.Today.AddDays(1); CheckDateOrg = DateTime.Now; RiscLevelLess = 83; RiscLevelMore = 0; /* SearchCommand = new RelayCommand(Search, CanSearch);*/ }
public SearchWievModelPers() { _countryRepository = new CountryRepository(); //создаем экземпляр класса CountryRepository, который унаследован от интрефейса ICountryRepository List <CountryModel> countries = _countryRepository.GetCountries(); // создаем список объектов с типом CountryModel при помощи метода обязательного (Интрерфес) методом GetCountries из репы Countries = CountryMapper.CountryModelToCountryViewModel(countries); // при помощи статического метода CountryModelToCountryViewModel из класса CountryMapper приводим тип из Модели во Вью модель, чтобы наша вью модель могла работать с данными }
/// <summary> /// Given certain conditions. /// </summary> protected override void Given() { input = new Country { Name = "Germany" }; classUnderTest = new CountryMapper(); }
public List <CountryViewModel> GetCountries(string columnName, string searchString) { List <Country> entities; switch (columnName.ToLower()) { case "name": entities = _repository.GetByCountryName(searchString); break; case "path": entities = _repository.GetByCountryPath(searchString); break; default: entities = _repository.GetAll(); break; } if (entities == null) { throw new Exception(LOCALIZATION_COUNTRY_NOT_FOUND); } return(CountryMapper.MapToCountryViewModel(entities)); }
public IActionResult PutCountry(int continentId, int countryId, [FromBody] CountryInApi countryInApi) { logger.LogInformation($"Post api/continent/{continentId}/country/{countryId} called"); if (countryInApi == null) { return(BadRequest()); } try { if (countryManager.Find(countryId) == null) { Domain.Models.Country country = CountryMapper.CountryInMapper(continentManager, countryInApi); Domain.Models.Country countryCreated = countryManager.AddCountry(country); CountryOutApi countryOut = CountryMapper.CountryOutMapper(hostUrl, countryCreated); return(CreatedAtAction(nameof(GetCountry), new { continentId = countryCreated.Continent.Id, countryId = countryCreated.Id }, countryOut)); } Domain.Models.Country countryUpdate = CountryMapper.CountryInMapper(continentManager, countryInApi); countryManager.UpdateCountry(countryId, countryUpdate, countryUpdate.Continent.Id); return(new NoContentResult()); } catch (Exception ex) { logger.LogError(ex.Message); return(BadRequest(ex.Message)); } }
private IQueryable <Country> Query() { var mapper = new CountryMapper(); var coutries = from c in DbQuery() select mapper.FromEntity(c); return(coutries.AsQueryable()); }
public async Task <IReadOnlyCollection <Country> > GetAllCountries() { var request = new RestRequest("all", Method.GET); var countryDtos = await this.PerformRequest <IReadOnlyCollection <CountryDto> >(request); return(CountryMapper.Map(countryDtos)); }
public SingleResult <Country> Get([FromODataUri] int key) { var mapper = new CountryMapper(); var country = from c in DbQuery().Where(x => x.Id.Equals(key)) select mapper.FromEntity(c); return(SingleResult.Create(country)); }
public NewOrganizationViewModel() { _newOrgrepo = new NewOrganizationRepository(); _countryRepository = new CountryRepository(); //создаем экземпляр класса CountryRepository, который унаследован от интрефейса ICountryRepository List <CountryModel> countries = _countryRepository.GetCountries(); // создаем список объектов с типом CountryModel при помощи метода обязательного (Интрерфес) методом GetCountries из репы var countryVM = CountryMapper.CountryModelToCountryViewModel(countries); // при помощи статического метода CountryModelToCountryViewModel из класса CountryMapper приводим тип из Модели во Вью модель, чтобы наша вью модель могла работать с данными _sectionRepository = new SectionRepository(); List <SectionModel> sections = _sectionRepository.GetSections(); var sectionVM = SectionMappers.SectionModelToSectionViewModel(sections); _riskListRepository = new RiskRepository(); var risks = _riskListRepository.GetRisks(); //ValueChanged - обработчик событий. В калькуляторе у нас есть событие, которое вызывается при смене значения в калькуляторе(при добавлении и удаоении значений) /// мы подписываемся на изменение ValueChanged RiskCalculator.ValueChanged += RiskCalculatorValueChanged; Person1 = new PersonViewModel(countryVM) { PrevLiquidated = new NegativeRiskCheckBoxViewModel(risks.PrevLiquidated), PrevBankruptcy = new NegativeRiskCheckBoxViewModel(risks.PrevBankruptcy), PrevExecuteProc = new NegativeRiskCheckBoxViewModel(risks.PrevExecuteProc), PrevStateDebt = new NegativeRiskCheckBoxViewModel(risks.PrevStateDebt), PrevTaxDebt = new NegativeRiskCheckBoxViewModel(risks.PrevTaxDebt), NegativDataPers = new NegativeRiskCheckBoxViewModel(risks.NegativData) }; Organization = new OrganizationViewModel(countryVM, sectionVM) { BrokerClient = new PositiveRiskCheckBoxViewModel(risks.BrokerClient), PrevBrokerClient = new PositiveRiskCheckBoxViewModel(risks.PrevBrokerClient), Manufacturer = new PositiveRiskCheckBoxViewModel(risks.Manufacturer), Reputation = new PositiveRiskCheckBoxViewModel(risks.Reputation), OwnershipOrg = new PositiveRiskCheckBoxViewModel(risks.OwnershipOrg), TaxDebt = new NegativeRiskCheckBoxViewModel(risks.TaxDebt), DebtsEnforcementDocuments = new NegativeRiskCheckBoxViewModel(risks.DebtsEnforcementDocuments), FalseBusiness = new NegativeRiskCheckBoxViewModel(risks.FalseBusiness), SpecialRisc = new NegativeRiskCheckBoxViewModel(risks.SpecialRisc), ExecuteProc = new NegativeRiskCheckBoxViewModel(risks.ExecuteProc), BankruptcyProc = new NegativeRiskCheckBoxViewModel(risks.BankruptcyProc), LiquidationProc = new NegativeRiskCheckBoxViewModel(risks.LiquidationProc), NegativData = new NegativeRiskCheckBoxViewModel(risks.NegativData), ExchengeTradingDisorders = new NegativeRiskCheckBoxViewModel(risks.ExchengeTradingDisorders), }; SaveCommand = new RelayCommand(Save, CanSave); ClearCommand = new RelayCommand(Clear); Risk = RiskCalculator.Value; AutoFill = new RelayCommand(FillOracleDataOrgPers); AutoFillViewModel = new AutoFillViewModel(); Countries = countryVM; }
public CountryEditModel GetCountryAsEditModel(Guid id) { var entity = _repository.Get(id); if (entity == null) { throw new Exception(LOCALIZATION_COUNTRY_NOT_FOUND); } return(CountryMapper.MapToCountryEditModel(entity)); }
public void MapCountryToDTO_ShouldReturnEmptyDTOIfFailed() { //Arrange //Act var sut = CountryMapper.MapCountryToDTO(null); //Assert Assert.AreEqual(sut.ID, null); Assert.AreEqual(sut.Name, null); Assert.AreEqual(sut.Breweries, null); }
public ReferenceDataService(IUnitOfWork unitOfWork, ICountryRestService countryRestService, IExchangeRateService exchangeRateService, CountryMapper countryMapper, ExchangeRateMapper exchangeRateMapper) { this.unitOfWork = unitOfWork; this.countryRestService = countryRestService; this.exchangeRateService = exchangeRateService; this.countryMapper = countryMapper; this.exchangeRateMapper = exchangeRateMapper; }
public List <Country> GetCountries(int continentId) { try { List <CountryDB> countryDBs = context.Countries.Where(x => x.ContinentId == continentId).ToList(); List <Country> countries = CountryMapper.CountryDBListToBusinessModel(countryDBs); return(countries); } catch (Exception ex) { throw ex; } }
protected void SetUp() { _countryRepository = new Mock <ICountryRepository>(); var countryMapper = new CountryMapper(); var countryService = new CountryService(_countryRepository.Object, countryMapper); _countriesController = new CountriesController(countryService) { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration() }; }
public void MapDTOToCountry_ShouldReturnEmptyCountryIfFailed() { //Arrange //Act var sut = CountryMapper.MapDTOToCountry(null); //Assert Assert.AreEqual(sut.ID, null); Assert.AreEqual(sut.Name, null); Assert.AreEqual(sut.Breweries, null); Assert.AreEqual(sut.CreatedOn, default); Assert.AreEqual(sut.ModifiedOn, null); Assert.AreEqual(sut.DeletedOn, null); Assert.AreEqual(sut.IsDeleted, false); }
public void Arrange() { _geocodeService = new Mock <IGeocodeService>(); _mappingService = new Mock <IMappingService>(); _vacanciesApi = new Mock <ILivevacanciesAPI>(); _vacanciesMapper = new VacanciesMapper(); _logger = new Mock <ILogger <VacanciesRepository> >(); _countryMapper = new CountryMapper(); _geocodeService.Setup(s => s.GetFromPostCode(It.IsAny <string>())).ReturnsAsync(coordinatesResponse); sut = new VacanciesRepository(_vacanciesApi.Object, _vacanciesMapper, _geocodeService.Object, _mappingService.Object, _logger.Object, _countryMapper, Mock.Of <IStandardsRepository>()); _standardIds = null; }
public Country AddCountry(Country country) { try { CountryDB countryDB = CountryMapper.CountryToDBModel(country); context.Countries.Add(countryDB); context.SaveChanges(); Country newCountry = CountryMapper.CountryDBToBusinessModel(countryDB, country.Continent); return(newCountry); } catch (Exception ex) { throw ex; } }
public void UpdateCountry(int id, Country countryUpdated, int newContinentId) { try { CountryDB countryDB = context.Countries.Find(id); CountryDB countryDBUpdated = CountryMapper.CountryToDBModel(countryUpdated); countryDB.ContinentId = newContinentId; countryDB.Name = countryDBUpdated.Name; countryDB.Population = countryDBUpdated.Population; countryDB.Surface = countryDBUpdated.Surface; } catch (Exception ex) { throw ex; } }
public Country Find(string countryName) { try { CountryDB countryDB = context.Countries.Where(x => x.Name == countryName).FirstOrDefault(); if (countryDB != null) { return(CountryMapper.CountryDBToBusinessModel(countryDB)); } return(null); } catch (Exception ex) { throw ex; } }
public ProductImportViewModel() { InitializeCommands(); m_Suppliers = SupplierMapper.GetAllSuppliers(); m_Producers = ProducerMapper.GetAllProducers(); m_Sorts = SortMapper.GetAllSorts(); m_Categories = ToolConstants.DEFAULT_FRUIT_CATEGORIES; m_Products = ProductMapper.GetAllProducts(); m_Origins = CountryMapper.GetAllCountries(); RaisePropertyChanged(nameof(Products)); RaisePropertyChanged(nameof(Sorts)); RaisePropertyChanged(nameof(Categories)); RaisePropertyChanged(nameof(Origins)); }
public void Arrange() { _geocodeService = new Mock <IGeocodeService>(); _mappingService = new Mock <IMappingService>(); _vacanciesApi = new Mock <ILivevacanciesAPI>(); _vacanciesMapper = new VacanciesMapper(); _logger = new Mock <ILogger <VacanciesRepository> >(); _countryMapper = new CountryMapper(); _geocodeService.Setup(s => s.GetFromPostCode(It.IsAny <string>())).ReturnsAsync(coordinatesResponse); _vacanciesApi.Setup(s => s.SearchApprenticeshipVacanciesByLocationAsync(It.IsAny <double>(), It.IsAny <double>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(GetSearchResults.MockSearchResults(coordinatesResponse)); _mappingService.Setup(s => s.GetStaticMapsUrl(It.IsAny <SFA.DAS.Campaign.Domain.Vacancies.Location>())).Returns("url"); sut = new VacanciesRepository(_vacanciesApi.Object, _vacanciesMapper, _geocodeService.Object, _mappingService.Object, _logger.Object, _countryMapper, Mock.Of <IStandardsRepository>()); }
public Country Find(int continentId, int countryId) { try { CountryDB countryDB = context.Countries.Find(countryId); ContinentDB continentDB = context.Continents.Find(continentId); if (continentDB != null && countryDB != null) { countryDB.ContinentId = continentId; countryDB.Continent = continentDB; Country country = CountryMapper.CountryDBToBusinessModel(countryDB); return(country); } return(null); } catch (Exception ex) { throw ex; } }
public void CountryMapper_Maps_Correctly() { var mapper = new CountryMapper(); var source = new ApiCountry() { iso3166 = "IN", total_holidays = 22, supported_languages = 2, uuid = "foo", country_name = "India" }; var destination = new Country(); destination = mapper.Convert(source, destination, null); destination.ShouldNotBeNull(); destination.CountryName.ShouldBe("India"); destination.Iso3166.ShouldBe("IN"); destination.TotalHolidays.ShouldBe(22); destination.Uuid.ShouldBe("foo"); destination.SupportedLanguages.ShouldBe(2); }
public CascadingDropDownNameValue[] GetCountrie(string knownCategoryValues, string category, string contextKey) { List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>(); List<CountryEntity> list = new CountryMapper().List(""); foreach (CountryEntity ent in list) { CascadingDropDownNameValue cdnv; if (ent.Title == contextKey) { cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString(), true); } else { cdnv = new CascadingDropDownNameValue(ent.Title, ent.Id.ToString()); } values.Add(cdnv); } return values.ToArray(); }