Пример #1
0
        public BE.CityStateZip InsertCityStateZip(BE.CityStateZip entity)
        {
            //@@NEW
            // Check if a CityStateZip already exists with this ZipCode.
            BE.CityStateZip existingEntity = GetCityStateZipCodeByZipCode(entity.ZipCode);
            DA.CityStateZipGateway gateway = new DA.CityStateZipGateway();
            if (null != existingEntity)
            {// existing entity - problematic if first entry contains wrong city/state
                if (!existingEntity.Equals(entity))
                {// argument entity contains different city/state => update with these values
                    //// entity comes without guid from UI
                    entity.CityStateZipGuid = existingEntity.CityStateZipGuid;
                    gateway.Update(entity.ToDataEntity());
                    // should return new value
                    existingEntity = this.GetCityStateZipCodeByZipCode(entity.ZipCode);
                }

                return existingEntity;
            }

            //@@NEW - removed try/catch. insert returns DA entity (with new data). this method now returns an entity.
            DA.CityStateZip result = gateway.Insert(entity.ToDataEntity());
            return result.ToBusinessEntity();
        }
Пример #2
0
 public void UpdateCityStateZip(BE.CityStateZip entity)
 {
     DA.CityStateZipGateway gateway = new DA.CityStateZipGateway();
     gateway.Update(entity.ToDataEntity());
 }