예제 #1
0
        public void updateCity([FromBody] CityDto citytdo)
        {
            City city = _mapper.Map <City>(citytdo);

            _city.Update(city);
        }
예제 #2
0
        public async Task <IActionResult> Save(CityDto city)
        {
            var newcity = await _cityService.AddAsync(_mapper.Map <City>(city));

            return(Created(string.Empty, _mapper.Map <CityDto>(newcity)));
        }
예제 #3
0
        public CityDto GetByName(string name)
        {
            CityDto city = _cityList.FirstOrDefault(x => x.Name == name);

            return(city);
        }
예제 #4
0
        //[Route("[action]")]
        public IActionResult GetCityDataTest(int id, bool includeRelations = false)
        {
            if (_cityControllerParameters_Object._use_Lazy_Loading_On_City_Controller)
            {
                if (false == includeRelations)
                {
                    _repositoryWrapper.CityInfoRepositoryWrapper.DisableLazyLoading();

                    var cityEntity = _repositoryWrapper.CityInfoRepositoryWrapper.FindOne(id);

                    if (null == cityEntity)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        if (_cityControllerParameters_Object._show_Empty_Related_Date_Fields)
                        {
                            CityDto CityDto_Object = _mapper.Map <CityDto>(cityEntity);
                            return(Ok(CityDto_Object));
                        }
                        else
                        {
                            CityDtoMinusRelations CityDto_Object = _mapper.Map <CityDtoMinusRelations>(cityEntity);
                            return(Ok(CityDto_Object));
                        }
                    }
                }
                else  // true == includeRelations
                {
                    _repositoryWrapper.CityInfoRepositoryWrapper.EnableLazyLoading();

                    var cityEntity = _repositoryWrapper.CityInfoRepositoryWrapper.FindOne(id);

                    if (null == cityEntity)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        CityDto CityDto_Object = _mapper.Map <CityDto>(cityEntity);
                        if (_cityControllerParameters_Object._show_Cyclic_Data)
                        {
                            return(Ok(cityEntity));
                        }
                        else
                        {
                            return(Ok(CityDto_Object));
                        }
                    }
                }
            }
            else  // !_use_Lazy_Loading_On_City_Controller
            {
                _repositoryWrapper.CityInfoRepositoryWrapper.DisableLazyLoading();

                if (false == includeRelations)
                {
                    var cityEntity = _repositoryWrapper.CityInfoRepositoryWrapper.GetCity(id, includeRelations);

                    if (null == cityEntity)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        if (_cityControllerParameters_Object._show_Empty_Related_Date_Fields)
                        {
                            var CityDto_Object = _mapper.Map <CityDto>(cityEntity);
                            return(Ok(CityDto_Object));
                        }
                        else
                        {
                            var CityDto_Object = _mapper.Map <CityDtoMinusRelations>(cityEntity);
                            return(Ok(CityDto_Object));
                        }
                    }
                }
                else  // true == includeRelations
                {
                    var cityEntity = _repositoryWrapper.CityInfoRepositoryWrapper.GetCity(id, includeRelations);

                    if (null == cityEntity)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        CityDto CityDto_Object = _mapper.Map <CityDto>(cityEntity);

                        if (_cityControllerParameters_Object._show_Cyclic_Data)
                        {
                            return(Ok(cityEntity));
                        }
                        else
                        {
                            return(Ok(CityDto_Object));
                        }
                    }
                }
            }
        }
예제 #5
0
 public Task <CityDto> UpdateAsync(int id, CityDto input)
 {
     throw new System.NotImplementedException();
 }
예제 #6
0
 public CityDto Add(CityDto subject)
 {
     return(cityStorage.Add(subject));
 }
예제 #7
0
 public Task <DinazorResult> Update(CityDto t)
 {
     throw new System.NotImplementedException();
 }
예제 #8
0
 public void AttachPointOfInterestToCity(CityDto city, PointOfInterestDto pointOfInterest)
 {
     city.PointsOfInterest.Add(pointOfInterest);
 }
        public void CityDto_Property_Count()
        {
            var city = new CityDto();

            Assert.AreEqual(6, city.GetType().GetProperties().Count());
        }
예제 #10
0
 public async Task <DinazorResult> Save(CityDto t)
 {
     return(await _cityOperation.Save(t));
 }
 // POST: api/Cities
 public CityDto Post(CityDto city)
 {
     CityRepository.Instance.Add(city);
     return(city);
 }
예제 #12
0
        public IActionResult GetCurrentWeather(CityDto city)
        {
            City findCity = _db.Cities.Where(c => c.Key == city.Key).FirstOrDefault();

            if (findCity == null)
            {
                findCity = new City()
                {
                    CityName = city.Name,
                    Key      = city.Key,
                    Country  = city.Country
                };
                _db.Cities.Add(findCity);
                _db.SaveChanges();
            }

            Weather findWeather = _db.Weathers.Where(w => w.Key == city.Key).FirstOrDefault();

            if (findWeather != null && findWeather.LastUpdate.AddDays(1) > DateTime.Now)
            {
                Favorite   fav        = _db.Favorites.Where(f => f.CityId == findCity.CityId).FirstOrDefault();
                WeatherDto weatherObj = new WeatherDto()
                {
                    CityName    = city.Name,
                    Country     = city.Country,
                    Key         = city.Key,
                    Temperature = findWeather.Temperature,
                    WeatherText = findWeather.WeatherText,
                    IsFavorite  = fav != null
                };
                return(Ok(weatherObj));
            }

            try
            {
                WeatherAPIDto weatherAPIObj = getWeatherFromAPI(city.Key);
                if (findWeather != null)
                {
                    findWeather.Temperature = weatherAPIObj.Temperature.Metric.Value;
                    findWeather.WeatherText = weatherAPIObj.WeatherText;
                    _db.Update(findWeather);
                }
                else
                {
                    findWeather = new Weather()
                    {
                        CityId      = findCity.CityId,
                        Key         = findCity.Key,
                        Temperature = weatherAPIObj.Temperature.Metric.Value,
                        WeatherText = weatherAPIObj.WeatherText,
                        LastUpdate  = DateTime.Now
                    };
                    _db.Add(findWeather);
                }
                _db.SaveChanges();

                Favorite   fav        = _db.Favorites.Where(f => f.CityId == findCity.CityId).FirstOrDefault();
                WeatherDto weatherObj = new WeatherDto()
                {
                    CityName    = city.Name,
                    Country     = city.Country,
                    Key         = city.Key,
                    Temperature = findWeather.Temperature,
                    WeatherText = findWeather.WeatherText,
                    IsFavorite  = fav != null
                };
                return(Ok(weatherObj));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(StatusCode(500, ModelState));
        }
예제 #13
0
 public CityDto CreateCity(CityDto dto)
 {
     return(new CountryLogic().CreateCity(dto));
 }
예제 #14
0
 public static void MapToDto(this CityDto cityDto, CityViewModel cityViewModel)
 {
     cityDto.Id   = cityViewModel.Id == null ? int.MinValue : cityViewModel.Id.Value;
     cityDto.Name = cityViewModel.Name;
 }
예제 #15
0
        public IActionResult Update([FromBody] CityDto obj, [FromHeader] string Authorization)
        {
            CityDto newObj = _repo.Update(obj);

            return(Ok(newObj));
        }
예제 #16
0
        public PointOfInterestDto GetOnePointOfInterest(CityDto city, int pointOfInterestId)
        {
            var entity = city.PointsOfInterest.SingleOrDefault(e => e.Id == pointOfInterestId);

            return(entity);
        }
 public async Task <ActionResponse <CityDto> > UpdateCity([FromBody] CityDto entityDto)
 {
     return(await locationService.UpdateCity(entityDto));
 }
예제 #18
0
 public Task <CityDto> CreateAsync(CityDto input)
 {
     throw new System.NotImplementedException();
 }
예제 #19
0
 public void CreateCity(CityDto cityDto)
 {
     throw new System.NotImplementedException();
 }
예제 #20
0
 public void SaveCity([FromBody] CityDto dto)
 {
     cityService.saveCity(dto);
 }
예제 #21
0
 public void UpdateCityInfo(CityDto city)
 {
     SelectedCity  = city;
     Organizations = new ObservableCollection <OrganizationDto>(SelectedCity.Organizations);
     Contacts      = null;
 }
예제 #22
0
 public void Update(CityDto subject)
 {
     cityStorage.Update(subject);
 }
 public static int newDtoCity(CityDto CityDto)
 {
     return(CityManager.NewCity(CityDto));
 }
예제 #24
0
 private async Task CreateAsync(CityDto input)
 {
     var city = ObjectMapper.Map <City>(input);
     await _cityRepository.InsertAsync(city);
 }
 public static void editDtoCity(CityDto CityDto)
 {
     CityManager.editCity(CityDto);
 }
예제 #26
0
        public void Post([FromBody] CityDto city)
        {
            City result = _mapper.Map <City>(city);

            _city.Create(result);
        }
예제 #27
0
        public async Task <GetFilterListResponse> GetFilterList()
        {
            try
            {
                var countries = await _listingRepository.GetAllCounties();

                var provinces = await _listingRepository.GetAllProvinces();

                var listingtypes = await _listingRepository.GetAllListings();

                var cities = await _listingRepository.GetAllCities();

                GetFilterListResponse filterListResponse = new GetFilterListResponse();
                filterListResponse.CountryList  = new List <CountryDto>();
                filterListResponse.ListingTypes = new List <ListingDto>();

                foreach (var listingType in listingtypes)
                {
                    ListingDto listingDto = new ListingDto()
                    {
                        ListingFilterName = listingType.ListingName,
                        ListingType       = listingType.Id
                    };

                    filterListResponse.ListingTypes.Add(listingDto);
                }

                foreach (var country in countries)
                {
                    var countryDto = new CountryDto();

                    countryDto.CountryType = country.Id;
                    countryDto.CountryName = country.CountryName;
                    countryDto.Provinces   = new List <ProvinceDto>();

                    foreach (var province in provinces)
                    {
                        if (province.CountryRefId == country.Id)
                        {
                            var provinceDto = new ProvinceDto();
                            provinceDto.Cities       = new List <CityDto>();
                            provinceDto.ProvinceType = province.Id;
                            provinceDto.ProvinceName = province.ProvinceName;

                            foreach (var city in cities)
                            {
                                if (city.CountryRefId == country.Id && city.ProvinceRefId == province.Id)
                                {
                                    var cityDto = new CityDto()
                                    {
                                        CityName = city.RegionName,
                                        CityType = city.Id
                                    };

                                    provinceDto.Cities.Add(cityDto);
                                }
                            }
                            countryDto.Provinces.Add(provinceDto);
                        }
                    }
                    filterListResponse.CountryList.Add(countryDto);
                }
                return(filterListResponse);
            }
            catch (Exception ex)
            {
                _logger.LogError($"error while constructing filter list: {ex}");
                throw ex.GetBaseException();
            }
        }
예제 #28
0
 public void UpdateCity(CityDto input)
 {
     var instanse = Mapper.Map<City>(input);
     this.unitOfWork.Entities<City, int>().Update(instanse);
 }
예제 #29
0
 public List <PointOfInterestDto> GetAllPointsOfInterest(CityDto city)
 {
     return(city.PointsOfInterest.ToList());
 }
예제 #30
0
        public IActionResult Update(CityDto city)
        {
            var updatecity = _cityService.Update(_mapper.Map <City>(city));

            return(Ok(_mapper.Map <CityDto>(updatecity)));
        }
예제 #31
0
 public CityCreateModel(CityDto city)
 {
     Name        = city.Name;
     Description = city.Description;
 }