Пример #1
0
        public PaymentInfo GetByPK(Guid paymentInfoGuid)
        {
            if (Guid.Empty == paymentInfoGuid)
            { return new PaymentInfo(); }

            try
            {
                PaymentInfo daPaymentInfo = new PaymentInfo();
                using (PSS2012DataContext context = this.DataContext)
                {
                    daPaymentInfo = (
                        from items in context.PaymentInfos
                        where items.PaymentInfoGuid == paymentInfoGuid
                        select items).SingleOrDefault();
                }

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

                return daPaymentInfo;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
        }
Пример #2
0
        public List<PaymentInfo> GetAllWithUndefined()
        {
            PaymentInfo undefinedPaymentInfo = new PaymentInfo()
            {
                PaymentInfoGuid = Guid.Empty,
                PaymentInfoID = 0,
                AmazonToken = "Undefined",
            };

            List<PaymentInfo> response = this.GetAll().ToList();
            response.Add(undefinedPaymentInfo);

            return response;
        }
Пример #3
0
        /// <summary>
        /// Inserts paymentInfo business entity into the data store.
        /// </summary>
        /// <param name="entity">The paymentInfo business entity to insert.</param>
        /// <returns>The paymentInfo identifier.</returns>
        public PaymentInfo Insert(PaymentInfo entity)
        {
            //@@NEW - changed return type to entity type.
            try
            {
                using (PSS2012DataContext context = DataContext)
                {
                    entity.PaymentInfoGuid = Guid.NewGuid();

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

                //@@NEW - returning full entity.
                return entity;
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
        }
Пример #4
0
        public void Update(PaymentInfo entity)
        {
            if (Guid.Empty == entity.PaymentInfoGuid)
                throw new PrimaryKeyMissingException("PaymentInfo", entity, "update");

            try
            {
                using (PSS2012DataContext context = DataContext)
                {
                    // Get the entity to update.
                    PaymentInfo paymentInfoToUpdate = GetByPK(entity.PaymentInfoGuid);
                    context.PaymentInfos.Attach(paymentInfoToUpdate);
                    // Set the new values.
                    //paymentInfoToUpdate.PaymentInfoID = entity.PaymentInfoID;
                    paymentInfoToUpdate.AmazonToken = entity.AmazonToken;

                    // Perform the update.
                    context.SubmitChanges();
                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw this.HandleSqlException(ex);
            }
        }
Пример #5
0
        public static DA.PaymentInfo ToDataEntity(this BE.PaymentInfo bePaymentInfo)
        {
            DA.PaymentInfo paymentInfoResult = new DA.PaymentInfo()
            {
                PaymentInfoGuid = bePaymentInfo.PaymentInfoGuid,
                PaymentInfoID = bePaymentInfo.PaymentInfoID,
                AmazonToken = bePaymentInfo.AmazonToken,
            };

            return paymentInfoResult;
        }