Esempio n. 1
0
 public async Task CreateOrUpdateCity(CreateCityInput input)
 {
     if (input.Id != 0)
     {
         await UpdateCityAsync(input);
     }
     else
     {
         await CreateCityAsync(input);
     }
 }
Esempio n. 2
0
        public virtual async Task CreateCityAsync(CreateCityInput input)
        {
            var City = input.MapTo <City>();
            var val  = _cityRepository
                       .GetAll().Where(p => p.CityName == input.CityName || p.CityCode == input.CityCode).FirstOrDefault();

            if (val == null)
            {
                await _cityRepository.InsertAsync(City);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in City Name '" + input.CityName + "' or City Code '" + input.CityCode + "'...");
            }
        }
Esempio n. 3
0
        public virtual async Task UpdateCityAsync(CreateCityInput input)
        {
            var city = await _cityRepository.GetAsync(input.Id);

            ObjectMapper.Map(input, city);

            var val = _cityRepository
                      .GetAll().Where(p => (p.CityName == input.CityName || p.CityCode == input.CityCode) && p.Id != input.Id).FirstOrDefault();

            if (val == null)
            {
                await _cityRepository.UpdateAsync(city);
            }
            else
            {
                throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in City Name '" + input.CityName + "' or City Code '" + input.CityCode + "'...");
            }
        }