Ejemplo n.º 1
0
        public virtual GiftCardStore UpdateGiftCardStore(GiftCardStore entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            GiftCardStore other = GetGiftCardStore(entity.GiftCardId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update GiftCardStore set  [ID]=@ID
							, [StoreID]=@StoreID
							, [CreatedOn]=@CreatedOn 
							 where GiftCardID=@GiftCardID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@GiftCardID", entity.GiftCardId)
                , new SqlParameter("@ID", entity.Id)
                , new SqlParameter("@StoreID", entity.StoreId)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetGiftCardStore(entity.GiftCardId));
        }
Ejemplo n.º 2
0
        public virtual GiftCardStore InsertGiftCardStore(GiftCardStore entity)
        {
            GiftCardStore other = new GiftCardStore();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into GiftCardStore ( [GiftCardID]
				,[ID]
				,[StoreID]
				,[CreatedOn] )
				Values
				( @GiftCardID
				, @ID
				, @StoreID
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@GiftCardID", entity.GiftCardId)
                    , new SqlParameter("@ID", entity.Id)
                    , new SqlParameter("@StoreID", entity.StoreId)
                    , new SqlParameter("@CreatedOn", entity.CreatedOn)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetGiftCardStore(Convert.ToInt32(identity)));
            }
            return(entity);
        }