Ejemplo n.º 1
0
        public FacilityPhoto GetByPK(Guid facilityPhotoGuid)
        {
            if (Guid.Empty == facilityPhotoGuid)
            { return new FacilityPhoto(); }

            try
            {
                FacilityPhoto daFacilityPhoto = new FacilityPhoto();
                using (PSS2012DataContext context = this.DataContext)
                {
                    daFacilityPhoto = (
                        from items in context.FacilityPhotos
                        where items.FacilityPhotoGuid == facilityPhotoGuid
                        select items).SingleOrDefault();
                }

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

                return daFacilityPhoto;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
        }
Ejemplo n.º 2
0
        public List<FacilityPhoto> GetAllWithUndefined()
        {
            FacilityPhoto undefinedFacilityPhoto = new FacilityPhoto()
            {
                FacilityPhotoGuid = Guid.Empty,
                PhotoUri = "Undefined",
                FacilityGuid = Guid.Empty,
            };

            List<FacilityPhoto> response = this.GetAll().ToList();
            response.Add(undefinedFacilityPhoto);

            return response;
        }
Ejemplo n.º 3
0
        public static DA.FacilityPhoto ToDataEntity(this BE.FacilityPhoto beFacilityPhoto)
        {
            DA.FacilityPhoto facilityPhotoResult = new DA.FacilityPhoto()
            {
                FacilityPhotoGuid = beFacilityPhoto.FacilityPhotoGuid,
                PhotoUri = beFacilityPhoto.PhotoUri,
                FacilityGuid = beFacilityPhoto.FacilityGuid,
            };

            return facilityPhotoResult;
        }
Ejemplo n.º 4
0
        public void Update(FacilityPhoto entity)
        {
            if (Guid.Empty == entity.FacilityPhotoGuid)
                throw new PrimaryKeyMissingException("FacilityPhoto", entity, "update");

            try
            {
                using (PSS2012DataContext context = this.DataContext)
                {
                    // Get the entity to update.
                    FacilityPhoto facilityPhotoToUpdate = GetByPK(entity.FacilityPhotoGuid);
                    context.FacilityPhotos.Attach(facilityPhotoToUpdate);
                    // Set the new values.
                    facilityPhotoToUpdate.PhotoUri = entity.PhotoUri;
                    facilityPhotoToUpdate.FacilityGuid = entity.FacilityGuid;

                    // Perform the update.
                    context.SubmitChanges();
                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Inserts facilityPhoto business entity into the data store.
        /// </summary>
        /// <param name="entity">The facilityPhoto business entity to insert.</param>
        /// <returns>The facilityPhoto identifier.</returns>
        public FacilityPhoto Insert(FacilityPhoto entity)
        {
            //@@NEW - changed return type to entity type.
            try
            {
                using (PSS2012DataContext context = this.DataContext)
                {
                    entity.FacilityPhotoGuid = Guid.NewGuid();

                    context.FacilityPhotos.InsertOnSubmit(entity);
                    context.SubmitChanges();
                }

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