public FacilityLocationCriteria GetByPK(Guid facilityGuid, Guid cityStateZipGuid)
        {
            if (Guid.Empty == facilityGuid || Guid.Empty == cityStateZipGuid)
            { return new FacilityLocationCriteria(); }

            try
            {
                FacilityLocationCriteria daFacilityLocationCriteria = new FacilityLocationCriteria();
                using (PSS2012DataContext context = this.DataContext)
                {
                    daFacilityLocationCriteria = (
                        from items in context.FacilityLocationCriterias
                        where items.FacilityGuid == facilityGuid && items.CityStateZipGuid == cityStateZipGuid
                        select items).SingleOrDefault();
                }

                if (null == daFacilityLocationCriteria)
                {
                    throw new DataAccessException("FacilityLocationCriteria no longer exists.");
                }

                return daFacilityLocationCriteria;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public static DA.FacilityLocationCriteria ToDataEntity(this BE.FacilityLocationCriteria beFacilityLocationCriteria)
        {
            DA.FacilityLocationCriteria facilityLocationCriteriaResult = new DA.FacilityLocationCriteria()
            {
                FacilityGuid = beFacilityLocationCriteria.FacilityGuid,
                CityStateZipGuid = beFacilityLocationCriteria.CityStateZipGuid,
            };

            return facilityLocationCriteriaResult;
        }
        public void Update(FacilityLocationCriteria entity)
        {
            if (Guid.Empty == entity.FacilityGuid || Guid.Empty == entity.CityStateZipGuid)
                throw new PrimaryKeyMissingException("FacilityLocationCriteria", entity, "update");

            try
            {
                using (PSS2012DataContext context = DataContext)
                {
                    // Get the entity to update.
                    FacilityLocationCriteria facilityLocationCriteriaToUpdate = GetByPK(entity.FacilityGuid, entity.CityStateZipGuid);

                    // Set the new values.

                    // Perform the update.
                    context.SubmitChanges();
                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Inserts facilityLocationCriteria business entity into the data store.
        /// </summary>
        /// <param name="entity">The facilityLocationCriteria business entity to insert.</param>
        /// <returns>The facilityLocationCriteria identifier.</returns>
        public FacilityLocationCriteria Insert(FacilityLocationCriteria entity)
        {
            //@@NEW - changed return type to entity type.
            try
            {
                using (PSS2012DataContext context = DataContext)
                {
                    //@@NEW - removed assignments for entity properties to themselves.
                    context.FacilityLocationCriterias.InsertOnSubmit(entity);
                    context.SubmitChanges();
                }

                //@@NEW - returning full entity.
                return entity;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }