public void UpdateCounty(CountyModel County)
        {
            var county = _untoldContext.DictionaryCounty.Find(County.CountyId);

            county.CountyName = County.CountyName;
            _untoldContext.SaveChanges();
        }
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            CityModel   city   = (CityModel)cmbCity.SelectedItem;
            CountyModel county = (CountyModel)cmbCounty.SelectedItem;


            int clientId = clientIdValue;

            //MessageBox.Show(cmbCity.SelectedIndex.ToString());
            int    clientAddressid = clientAddressIdValue;
            int    cityId          = (cmbCity.SelectedIndex == -1)? -1 :city.CityId;
            string cityName        = (cmbCity.SelectedIndex == -1) ? null : city.CityName;
            //MessageBox.Show(cityId.ToString());
            int          countyId   = (cmbCounty.SelectedIndex == -1) ? -1 : county.CountyId;
            string       countyName = (cmbCounty.SelectedIndex == -1) ? null : county.CountyName;
            string       streetName = txtStreetName.Text;
            string       streetNo   = txtStreetNo.Text;
            BLAddress    bl         = new BLAddress();
            AddressModel address    = bl.GetAddress(clientAddressid, cityName, countyName, streetName, streetNo);

            address.status = 2;
            parent.RefreshGridUpdate(address);
            //bl.UpdateAddress(clientId, clientAddressid, cityId, countyId, streetName, streetNo);
            //bl.AddAddress(clientId, cityId, countyId, streetName, streetNo);
            //MessageBox.Show("Adresa a fost modificata cu succes.");
        }
示例#3
0
 public StreamDetails()
 {
     Pal          = new PalCollection();
     TroutStreams = new TroutStreamCollection();
     Restrictions = new List <RestrictionCollection>();
     Lakes        = new LakeCollection();
     LocalNames   = new string[0];
     Counties     = new CountyModel[0];
 }
示例#4
0
 private void OpenCountyDialog()
 {
     _showDialog.ShowDialog(nameof(CountySelectDialog), null, result =>
     {
         if (result.Result == ButtonResult.OK)
         {
             CountyModel county = result.Parameters.GetValue <CountyModel>("county");
             City.Zupanija      = county.Naziv;
         }
     });
 }
        public void InsertCounty(CountyModel county)
        {
            var County = new DictionaryCounty()
            {
                DictionaryCountyId = county.CountyId,
                CountyName         = county.CountyName,
                CountryId          = county.CountryId
            };

            _untoldContext.DictionaryCounty.Add(County);
            _untoldContext.SaveChanges();
        }
 public UpdateCounty(int countyId, UpdateCountyModel county)
 {
     County = new CountyModel
     {
         Id       = countyId,
         Name     = county.Name,
         Code     = county.Code,
         Diaspora = county.Diaspora,
         Order    = county.Order,
         NumberOfPollingStations = county.NumberOfPollingStations
     };
 }
示例#7
0
 public async Task PostCounty(CountyModel county)
 {
     using (HttpResponseMessage response = await _apiService.ApiClient.PostAsJsonAsync("/api/Counties", county))
     {
         if (response.IsSuccessStatusCode)
         {
         }
         else
         {
             throw new Exception(response.ReasonPhrase);
         }
     }
 }
示例#8
0
        public void UpdateCounty(CountyModel county)
        {
            try
            {
                _sql.StartTransaction("AccountingConnStr");

                _sql.SaveDataInTransaction("dbo.spCounties_Update", county);
            }
            catch (System.Exception)
            {
                _sql.RollBackTransaction();
                throw;
            }
        }
        public void UpdateCounty(CountyModel County)
        {
            string SqlText = "update DictionaryCounty" +
                             " set CountyName = @CountyName" +
                             " where DictionaryCountyId = @DictionaryCountyId";
            SqlCommand sqlCommand = new SqlCommand(SqlText, _sqlConnection);

            sqlCommand.Parameters.Add("@CountyName", SqlDbType.NVarChar);
            sqlCommand.Parameters["@CountyName"].Value = County.CountyName;
            sqlCommand.Parameters.Add("@DictionaryCountyId", SqlDbType.Int);
            sqlCommand.Parameters["@DictionaryCountyId"].Value = County.CountyId;


            sqlCommand.ExecuteNonQuery();
        }
        public void InsertCounty(CountyModel County)
        {
            string SqlText = "insert into DictionaryCounty values(@DictionaryCountyId, @CountyName, @CountryId)";

            SqlCommand sqlCommand = new SqlCommand(SqlText, _sqlConnection);

            sqlCommand.Parameters.Add("@DictionaryCountyId", SqlDbType.Int);
            sqlCommand.Parameters["@DictionaryCountyId"].Value = County.CountyId;
            sqlCommand.Parameters.Add("@CountyName", SqlDbType.NVarChar);
            sqlCommand.Parameters["@CountyName"].Value = County.CountyName;
            sqlCommand.Parameters.Add("@CountryId", SqlDbType.Int);
            sqlCommand.Parameters["@CountryId"].Value = County.CountryId;

            sqlCommand.ExecuteNonQuery();
        }
        /// <summary>
        /// To the view model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static CountyViewModel ToViewModel(this CountyModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new CountyViewModel
            {
                CountyID        = model.CountyID,
                StateProvinceID = model.StateProvinceID,
                CountyName      = model.CountyName,
                OrganizationID  = model.OrganizationID
            };

            return(entity);
        }
        /// <summary>
        /// To the model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static CountyModel ToModel(this CountyViewModel entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new CountyModel
            {
                CountyID        = entity.CountyID,
                StateProvinceID = entity.StateProvinceID,
                CountyName      = entity.CountyName,
                OrganizationID  = entity.OrganizationID
            };

            return(model);
        }
示例#13
0
        public BindingList <CountyModel> CountyList()
        {
            BindingList <CountyModel> listaCounties = new BindingList <CountyModel>();
            DataTable   dt = new DataTable();
            DACountyGet da = new DACountyGet();

            dt = da.getCounty();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CountyModel county = new CountyModel();

                county.CountyId   = Convert.ToInt32(dt.Rows[i]["CountyId"].ToString());
                county.CountyName = dt.Rows[i]["CountyName"].ToString();

                listaCounties.Add(county);
            }
            return(listaCounties);
        }
示例#14
0
        private void BtnAddAddress_Click(object sender, EventArgs e)
        {
            CityModel   city   = (CityModel)cmbCityName.SelectedItem;
            CountyModel county = (CountyModel)cmbCountyName.SelectedItem;
            //cmbCityName.SelectedItem.
            //MessageBox.Show(city.CityId.ToString());
            int       clientId   = id;
            int       cityId     = city.CityId;
            int       countyId   = county.CountyId;
            string    cityName   = city.CityName;
            string    countyName = county.CountyName;
            string    streetName = txtStreetName.Text;
            string    streetNo   = txtStreetNo.Text;
            BLAddress bl         = new BLAddress();

            parent.RefreshGridAdd(bl.GetAddress(-1, cityName, countyName, streetName, streetNo));
            //bl.AddAddress(clientId, cityId, countyId, streetName, streetNo);
            //MessageBox.Show("Adresa a fost adaugata cu succes.");
        }
示例#15
0
        public BindingList <CountyModel> GetCountyBi()
        {
            DAClientAddress dac = new DAClientAddress();
            DataTable       dt  = new DataTable();

            dt = dac.GetCounty();

            BindingList <CountyModel> list = new BindingList <CountyModel>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CountyModel county = new CountyModel();
                county.CountyId   = Convert.ToInt32(dt.Rows[i]["CountyId"].ToString());
                county.CountyName = dt.Rows[i]["CountyName"].ToString();

                list.Add(county);
            }

            return(list);
        }
示例#16
0
        public List <CountyModel> GetCounties()
        {
            List <CountyModel> lista     = new List <CountyModel>();
            DAAddress          daAdrese  = new DAAddress();
            DataTable          dataTable = new DataTable();

            try
            {
                dataTable = daAdrese.GetCounties();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                CountyModel jud = new CountyModel();
                jud.CountyId   = Convert.ToInt32(dataTable.Rows[i]["CountyId"]);
                jud.CountyName = dataTable.Rows[i]["CountyName"].ToString();
                lista.Add(jud);
            }
            return(lista);
        }
 public IActionResult InsertCounty(CountyModel county)
 {
     _countyRepository.InsertCounty(county);
     return(Ok());
 }
        public void ItIsPossibleToMapTheModelsCounty()
        {
            var countyModel = new CountyModel
            {
                Id            = Guid.NewGuid(),
                Name          = Faker.Address.City(),
                CodeIbge      = Faker.RandomNumber.Next(1000000, 9999999),
                FederalUnitId = Guid.NewGuid(),
                CreateAt      = DateTime.Now,
                UpdateAt      = DateTime.Now
            };
            var listCountyEntity = new List <CountyEntity>();

            for (int i = 0; i < 5; i++)
            {
                var itemCountyEntity = new CountyEntity
                {
                    Id            = Guid.NewGuid(),
                    Name          = Faker.Address.City(),
                    CodeIbge      = Faker.RandomNumber.Next(1, 100000),
                    FederalUnitId = Guid.NewGuid(),
                    CreateAt      = DateTime.Now,
                    UpdateAt      = DateTime.Now,
                    FederalUnit   = new FederalUnitEntity
                    {
                        Id       = Guid.NewGuid(),
                        Name     = Faker.Address.UsState(),
                        Initials = Faker.Address.UsState().Substring(1, 3)
                    }
                };
                listCountyEntity.Add(itemCountyEntity);
            }
            #region Model => Entity
            //Model => Entity
            var countyEntity = Mapper.Map <CountyEntity>(countyModel);
            Assert.Equal(countyEntity.Id, countyModel.Id);
            Assert.Equal(countyEntity.Name, countyModel.Name);
            Assert.Equal(countyEntity.CodeIbge, countyModel.CodeIbge);
            Assert.Equal(countyEntity.FederalUnitId, countyModel.FederalUnitId);
            Assert.Equal(countyEntity.CreateAt, countyModel.CreateAt);
            Assert.Equal(countyEntity.UpdateAt, countyModel.UpdateAt);
            #endregion
            #region Entity => Dto
            //Entity => Dto
            var countyDto = Mapper.Map <CountyDto>(countyEntity);
            Assert.Equal(countyDto.Id, countyEntity.Id);
            Assert.Equal(countyDto.Name, countyEntity.Name);
            Assert.Equal(countyDto.CodeIbge, countyEntity.CodeIbge);
            Assert.Equal(countyDto.FederalUnitId, countyEntity.FederalUnitId);
            #endregion
            #region  CompleteDto => Entity
            // CompleteDto => Entity
            var countyCompleteDto = Mapper.Map <CountyCompleteDto>(listCountyEntity.FirstOrDefault());
            Assert.Equal(countyCompleteDto.Id, listCountyEntity.FirstOrDefault().Id);
            Assert.Equal(countyCompleteDto.Name, listCountyEntity.FirstOrDefault().Name);
            Assert.Equal(countyCompleteDto.CodeIbge, listCountyEntity.FirstOrDefault().CodeIbge);
            Assert.Equal(countyCompleteDto.FederalUnitId, listCountyEntity.FirstOrDefault().FederalUnitId);
            Assert.NotNull(countyCompleteDto.FederalUnit);
            #endregion
            #region List CountyDto => List CountyEntity
            // List CountyDto => List CountyEntity
            var listCountyDto = Mapper.Map <List <CountyDto> >(listCountyEntity);
            Assert.True(listCountyDto.Count() == listCountyEntity.Count());
            for (int i = 0; i < listCountyDto.Count(); i++)
            {
                Assert.Equal(listCountyDto[i].Id, listCountyEntity[i].Id);
                Assert.Equal(listCountyDto[i].Name, listCountyEntity[i].Name);
                Assert.Equal(listCountyDto[i].CodeIbge, listCountyEntity[i].CodeIbge);
                Assert.Equal(listCountyDto[i].FederalUnitId, listCountyEntity[i].FederalUnitId);
            }
            #endregion
            #region County Entity => County Create Result Dto
            // County Entity => County Create Result Dto
            var countyCreateResultDto = Mapper.Map <CountyCreateResultDto>(countyEntity);
            Assert.Equal(countyCreateResultDto.Id, countyEntity.Id);
            Assert.Equal(countyCreateResultDto.Name, countyEntity.Name);
            Assert.Equal(countyCreateResultDto.CodeIbge, countyEntity.CodeIbge);
            Assert.Equal(countyCreateResultDto.FederalUnitId, countyEntity.FederalUnitId);
            #endregion
            #region County Entity => County Update Result Dto
            // County Entity => County Update Result Dto
            var countyUpdateResultDto = Mapper.Map <CountyUpdateResultDto>(countyEntity);
            Assert.Equal(countyUpdateResultDto.Id, countyEntity.Id);
            Assert.Equal(countyUpdateResultDto.Name, countyEntity.Name);
            Assert.Equal(countyUpdateResultDto.CodeIbge, countyEntity.CodeIbge);
            Assert.Equal(countyUpdateResultDto.FederalUnitId, countyEntity.FederalUnitId);
            #endregion
            #region Dto => Model
            // Dto => Model
            var model = Mapper.Map <CountyModel>(countyDto);
            Assert.Equal(model.Id, countyDto.Id);
            Assert.Equal(model.Name, countyDto.Name);
            Assert.Equal(model.CodeIbge, countyDto.CodeIbge);
            Assert.Equal(model.FederalUnitId, countyDto.FederalUnitId);
            #endregion
            #region Model => Create Dto
            //Model => Create Dto
            var countyCreateDto = Mapper.Map <CountyCreateDto>(model);
            Assert.Equal(countyCreateDto.Name, model.Name);
            Assert.Equal(countyCreateDto.CodeIbge, model.CodeIbge);
            Assert.Equal(countyCreateDto.FederalUnitId, model.FederalUnitId);
            #endregion
            #region  Model => Update Dto
            //Model => Update Dto
            var countyUpdateDto = Mapper.Map <CountyUpdateDto>(model);
            Assert.Equal(countyUpdateDto.Id, model.Id);
            Assert.Equal(countyUpdateDto.Name, model.Name);
            Assert.Equal(countyUpdateDto.CodeIbge, model.CodeIbge);
            Assert.Equal(countyUpdateDto.FederalUnitId, model.FederalUnitId);
            #endregion
        }
 // Constructor
 public CountyLocatorViewModel()
 {
     County = new CountyModel();
 }
示例#20
0
 public void Post([FromBody] CountyModel county)
 {
     _countyData.InsertCounty(county);
 }
 public IActionResult UpdateCounty(CountyModel county)
 {
     _countyRepository.UpdateCounty(county);
     return(Ok());
 }