Beispiel #1
0
        public Click GetByPK(Guid clickGuid)
        {
            if (Guid.Empty == clickGuid)
            { return new Click(); }

            try
            {
                Click daClick = new Click();
                using (PSS2012DataContext context = this.DataContext)
                {
                    daClick = (
                        from items in context.Clicks
                        where items.ClickGuid == clickGuid
                        select items).SingleOrDefault();
                }

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

                return daClick;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
        }
Beispiel #2
0
        public List<Click> GetAllWithUndefined()
        {
            Click undefinedClick = new Click()
            {
                ClickGuid = Guid.Empty,
                FacilityGuid = Guid.Empty,
                ListingTypeGuid = Guid.Empty,
                TimeStamp = default(DateTime),
            };

            List<Click> response = this.GetAll().ToList();
            response.Add(undefinedClick);

            return response;
        }
Beispiel #3
0
        public static DA.Click ToDataEntity(this BE.Click beClick)
        {
            DA.Click clickResult = new DA.Click()
            {
                ClickGuid = beClick.ClickGuid,
                FacilityGuid = beClick.FacilityGuid,
                ListingTypeGuid = beClick.ListingTypeGuid,
                TimeStamp = beClick.TimeStamp,
            };

            return clickResult;
        }
Beispiel #4
0
        public void Update(Click entity)
        {
            if (Guid.Empty == entity.ClickGuid)
                throw new PrimaryKeyMissingException("Click", entity, "update");

            try
            {
                using (PSS2012DataContext context = DataContext)
                {
                    // Get the entity to update.
                    Click clickToUpdate = GetByPK(entity.ClickGuid);

                    // Set the new values.
                    clickToUpdate.FacilityGuid = entity.FacilityGuid;
                    clickToUpdate.ListingTypeGuid = entity.ListingTypeGuid;
                    clickToUpdate.TimeStamp = entity.TimeStamp;

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

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

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