Beispiel #1
0
        public async Task <bool> ImportProvinceFromAPIAsync(UserIdentity <int> issuer)
        {
            // UPDATE GET FROM APPSETTING
            string url = "https://thongtindoanhnghiep.co/api/city";

            try
            {
                var APIListItem = await GetAPIAsync(url);

                foreach (APIProvinceModel m in APIListItem.LtsItem)
                {
                    var province = new Province()
                    {
                        Name = m.Title,
                        Code = m.Id.ToString(),
                        Type = m.Type
                    };
                    province.CreateBy(issuer).UpdateBy(issuer);
                    _provinceRepository.Create(province);
                }
                if (await _uow.SaveChangesAsync() > 0)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception e)
            {
                throw e;
            }
        }