public async Task <IActionResult> SearchByCountryName([FromBody] CountryInputDto country)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var Places = await searchService.SearchByCountry(country);

            return(Ok(Places));
        }
 public async Task <Country> Update(CountryInputDto countryInputDto)
 {
     return(await _covid19RankingRepository.Update(new Country(countryInputDto.Name,
                                                               new List <Covid19Ranking> {
         new Covid19Ranking(
             countryInputDto.Summary.ActiveCases,
             countryInputDto.Summary.RecoveredCases,
             countryInputDto.Summary.FatalCases,
             countryInputDto.Summary.RankingPosition)
     })));
 }
示例#3
0
 public async Task CreateOrUpdateCountry(CountryInputDto input)
 {
     if (input.Id != 0)
     {
         await UpdateCountry(input);
     }
     else
     {
         await CreateCountry(input);
     }
 }
        public List <Movie> GetCountries(CountryInputDto input)
        {
            var temp = countryMovieRepository.GetQuery().Include(x => x.Country)
                       .Include(z => z.Movie).Where(u => u.Country.CountryName == input.CountryNames).Select(x => x.Movie).ToList();

            //CountryOutputDtos list = new CountryOutputDtos();
            //foreach (var item in temp) {
            //    list.movieTitles.Add(item);
            //}

            return(temp);
        }
示例#5
0
        public async Task CreateCountry(CountryInputDto input)
        {
            var country = input.MapTo<Country>();
            var val = _countryRepository
             .GetAll().Where(p => p.CountryCode == input.CountryCode || p.CountryName == input.CountryName).FirstOrDefault();

            if (val == null)
            {
                await _countryRepository.InsertAsync(country);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in country Name '" + input.CountryName + "' or country Code '" + input.CountryCode + "'...");
            }
        }
        public async Task <List <NameValue <string> > > GetProvinces(CountryInputDto input)
        {
            var result = new List <NameValue <string> >();
            var datas  = (await AsyncQueryableExecuter.ToListAsync(Repository.GetAll().Where(m => m.Country == input.Country)))
                         .Select(m => new { Id = m.Province, Name = m.Province }).Distinct().ToList();

            foreach (var data in datas)
            {
                var value = new NameValue()
                {
                    Value = data.Id.ToString(), Name = data.Name
                };
                result.Add(value);
            }
            return(result);
        }
示例#7
0
        public Task <List <CountryOutPutDto> > SearchByCountry(CountryInputDto country)
        {
            var CountryPlaces = TuristPlaceRepository.GetQuery()
                                .Include(x => x.Country)
                                .Include(o => o.City)
                                .Where(y => y.Country.Id == country.CountryId)
                                .Select(Z => mapper.Map <CountryOutPutDto>(Z))
                                .ToListAsync();

            if (CountryPlaces == null)
            {
                throw new KeyNotFoundException("برای این دسته بندی مکان توریستی وجود ندارد");
            }

            return(CountryPlaces);
        }
        public async Task <CountryDto> AddOrUpdate(CountryInputDto input)
        {
            var country = _countryRepository.FirstOrDefault(x => x.Id == input.Id);
            var isNew   = country == null;


            // -- Check if exist SortName
            var existSortName = await _countryRepository.FirstOrDefaultAsync(x => (isNew || (!isNew && x.Id != input.Id)) && x.ShortName.ToLower() == input.ShortName.ToLower().Trim());

            if (existSortName != null)
            {
                throw new UserFriendlyException("This Short Name already exists");
            }

            // -- Check if exist Alpha2Code
            var existAlpha2Code = await _countryRepository.FirstOrDefaultAsync(x => (isNew || (!isNew && x.Id != input.Id)) && x.Alpha2Code.ToLower() == input.Alpha2Code.ToLower().Trim());

            if (existAlpha2Code != null)
            {
                throw new UserFriendlyException("This Alpha 2 Code already exists");
            }

            // -- Check if exist Alpha3Code
            var existAlpha3Code = await _countryRepository.FirstOrDefaultAsync(x => (isNew || (!isNew && x.Id != input.Id)) && x.Alpha3Code.ToLower() == input.Alpha3Code.ToLower().Trim());

            if (existAlpha3Code != null)
            {
                throw new UserFriendlyException("This Alpha 3 Code already exists");
            }

            // -- Check if exist NumericCode
            var existNumericCode = await _countryRepository.FirstOrDefaultAsync(x => (isNew || (!isNew && x.Id != input.Id)) && x.NumericCode.ToLower() == input.NumericCode.ToLower().Trim());

            if (existNumericCode != null)
            {
                throw new UserFriendlyException("This Numeric Code already exists");
            }

            var countryLocal = ObjectMapper.Map(input, country);

            country = await _countryRepository.InsertOrUpdateAsync(countryLocal);

            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <CountryDto>(country));
        }
示例#9
0
        public async Task UpdateCountry(CountryInputDto input)
        {
            var country = await _countryRepository.GetAsync(input.Id);         
            country.LastModificationTime = DateTime.Now;
            ObjectMapper.Map(input, country);

            var val = _countryRepository
              .GetAll().Where(p => (p.CountryCode == input.CountryCode || p.CountryName == input.CountryName) && p.Id != input.Id).FirstOrDefault();

            if (val == null)
            {
                await _countryRepository.UpdateAsync(country);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in country Name '" + input.CountryName + "' or country Code '" + input.CountryCode + "'...");
            }

        }
示例#10
0
 //az model nabayad bargardoone
 public List <Movie> MovieBasedOnCountry([FromBody] CountryInputDto countryInput)
 {
     return(countryMovieService.GetCountries(countryInput));
 }