public CountryDto CreateCountry(CountryDto countryDto, int userId, int tenantId) { if (GetCountry(countryDto.CountryId, tenantId) != null) { return(EditCountry(countryDto, userId, tenantId)); } ValidateCountry(countryDto, tenantId); var countryObj = Mapper.Map <Country>(countryDto); foreach (var countryName in countryDto.TitleDictionary) { countryObj.CountryTranslations.Add(new CountryTranslation { Title = countryName.Value, Language = countryName.Key, }); } countryObj.CreationTime = Strings.CurrentDateTime; countryObj.CreatorUserId = userId; countryObj.TenantId = tenantId; _typeTranslationService.InsertRange(countryObj.CountryTranslations); _countryService.Insert(countryObj); SaveChanges(); return(countryDto); }