示例#1
0
        public static DA.Offering ToDataEntity(this BE.Offering beOffering)
        {
            DA.Offering offeringResult = new DA.Offering()
            {
                OfferingGuid = beOffering.OfferingGuid,
                OfferingID = beOffering.OfferingID,
                OfferingName = beOffering.OfferingName,
            };

            return offeringResult;
        }
示例#2
0
        public void Update(Offering entity)
        {
            if (Guid.Empty == entity.OfferingGuid)
                throw new PrimaryKeyMissingException("Offering", entity, "update");

            try
            {
                using (PSS2012DataContext context = DataContext)
                {
                    // Get the entity to update.
                    Offering offeringToUpdate = GetByPK(entity.OfferingGuid);

                    // Set the new values.
                    offeringToUpdate.OfferingID = entity.OfferingID;
                    offeringToUpdate.OfferingName = entity.OfferingName;

                    // Perform the update.
                    context.SubmitChanges();
                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
        }
示例#3
0
        public Offering GetByPK(Guid offeringGuid)
        {
            if (Guid.Empty == offeringGuid)
            { return new Offering(); }

            try
            {
                Offering daOffering = new Offering();
                using (PSS2012DataContext context = this.DataContext)
                {
                    daOffering = (
                        from items in context.Offerings
                        where items.OfferingGuid == offeringGuid
                        select items).SingleOrDefault();
                }

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

                return daOffering;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
        }
示例#4
0
        /// <summary>
        /// Inserts offering business entity into the data store.
        /// </summary>
        /// <param name="entity">The offering business entity to insert.</param>
        /// <returns>The offering identifier.</returns>
        public Offering Insert(Offering entity)
        {
            //@@NEW - changed return type to entity type.
            try
            {
                using (PSS2012DataContext context = DataContext)
                {
                    entity.OfferingGuid = Guid.NewGuid();

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

                //@@NEW - returning full entity.
                return entity;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
        }
示例#5
0
        public List<Offering> GetAllWithUndefined()
        {
            Offering undefinedOffering = new Offering()
            {
                OfferingGuid = Guid.Empty,
                OfferingID = 0,
                OfferingName = "Undefined",
            };

            List<Offering> response = this.GetAll().ToList();
            response.Add(undefinedOffering);

            return response;
        }