Пример #1
0
        public async Task <CountryItemViewModel> GetCountryItem(int countryId)
        {
            _sharedService.WriteLogs("GetCountryItem started by:" + _userSettings.UserName, true);

            try
            {
                var country = await _countryRepository.GetByIdAsync(countryId);

                Guard.Against.NullCountry(countryId, country);

                var vm = new CountryItemViewModel()
                {
                    Id              = country.Id,
                    Code            = country.Code,
                    English         = country.English,
                    French          = country.French,
                    ISO2CountryCode = country.ISO2CountryCode,
                    ISO3CountryCode = country.ISO3CountryCode,
                    CreatedDate     = country.CreatedDate,
                    CreatedBy       = country.CreatedBy,
                    ModifiedDate    = country.ModifiedDate,
                    ModifiedBy      = country.ModifiedBy
                };

                return(vm);
            }
            catch (Exception ex)
            {
                _sharedService.WriteLogs("GetCountryItem failed:" + ex.Message, false);

                var vm = new CountryItemViewModel();

                return(vm);
            }
        }
Пример #2
0
        public async Task UpdateCountryAsync(CountryItemViewModel country)
        {
            _sharedService.WriteLogs("UpdateCountryAsync started by:" + _userSettings.UserName, true);

            try
            {
                var _country = await _countryRepository.GetByIdAsync(country.Id);

                Guard.Against.NullCountry(country.Id, _country);

                _country.Code            = country.Code;
                _country.English         = country.English;
                _country.French          = country.French;
                _country.ISO2CountryCode = country.ISO2CountryCode;
                _country.ISO3CountryCode = country.ISO3CountryCode;
                _country.ModifiedDate    = DateTime.Now;
                _country.ModifiedBy      = _userSettings.UserName;

                await _countryRepository.UpdateAsync(_country);
            }
            catch (Exception ex)
            {
                _sharedService.WriteLogs("UpdateCountryAsync failed:" + ex.Message, false);
            }
        }
Пример #3
0
        public async Task CreateCountryAsync(CountryItemViewModel country)
        {
            _sharedService.WriteLogs("CreateCountryAsync started by:" + _userSettings.UserName, true);

            try
            {
                var _country = new Country();

                _country.Code            = country.Code;
                _country.English         = country.English;
                _country.French          = country.French;
                _country.ISO2CountryCode = country.ISO2CountryCode;
                _country.ISO3CountryCode = country.ISO3CountryCode;
                _country.CreatedDate     = DateTime.Now;
                _country.CreatedBy       = _userSettings.UserName;
                _country.ModifiedDate    = DateTime.Now;
                _country.ModifiedBy      = _userSettings.UserName;

                await _countryRepository.AddAsync(_country);
            }
            catch (Exception ex)
            {
                _sharedService.WriteLogs("CreateCountryAsync failed:" + ex.Message, false);
            }
        }