Exemplo n.º 1
0
        public virtual GiftCard UpdateGiftCard(GiftCard entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            GiftCard other = GetGiftCard(entity.GiftCardId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update GiftCard set  [GiftCardGUID]=@GiftCardGUID
							, [SerialNumber]=@SerialNumber
							, [PurchasedByCustomerID]=@PurchasedByCustomerID
							, [OrderNumber]=@OrderNumber
							, [ShoppingCartRecID]=@ShoppingCartRecID
							, [ProductID]=@ProductID
							, [VariantID]=@VariantID
							, [InitialAmount]=@InitialAmount
							, [Balance]=@Balance
							, [StartDate]=@StartDate
							, [ExpirationDate]=@ExpirationDate
							, [GiftCardTypeID]=@GiftCardTypeID
							, [EMailName]=@EMailName
							, [EMailTo]=@EMailTo
							, [EMailMessage]=@EMailMessage
							, [ValidForCustomers]=@ValidForCustomers
							, [ValidForProducts]=@ValidForProducts
							, [ValidForManufacturers]=@ValidForManufacturers
							, [ValidForCategories]=@ValidForCategories
							, [ValidForSections]=@ValidForSections
							, [DisabledByAdministrator]=@DisabledByAdministrator
							, [ExtensionData]=@ExtensionData
							, [CreatedOn]=@CreatedOn 
							 where GiftCardID=@GiftCardID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@GiftCardID", entity.GiftCardId)
                , new SqlParameter("@GiftCardGUID", entity.GiftCardGuid)
                , new SqlParameter("@SerialNumber", entity.SerialNumber ?? (object)DBNull.Value)
                , new SqlParameter("@PurchasedByCustomerID", entity.PurchasedByCustomerId)
                , new SqlParameter("@OrderNumber", entity.OrderNumber)
                , new SqlParameter("@ShoppingCartRecID", entity.ShoppingCartRecId)
                , new SqlParameter("@ProductID", entity.ProductId)
                , new SqlParameter("@VariantID", entity.VariantId)
                , new SqlParameter("@InitialAmount", entity.InitialAmount)
                , new SqlParameter("@Balance", entity.Balance)
                , new SqlParameter("@StartDate", entity.StartDate)
                , new SqlParameter("@ExpirationDate", entity.ExpirationDate)
                , new SqlParameter("@GiftCardTypeID", entity.GiftCardTypeId ?? (object)DBNull.Value)
                , new SqlParameter("@EMailName", entity.EmailName ?? (object)DBNull.Value)
                , new SqlParameter("@EMailTo", entity.EmailTo ?? (object)DBNull.Value)
                , new SqlParameter("@EMailMessage", entity.EmailMessage ?? (object)DBNull.Value)
                , new SqlParameter("@ValidForCustomers", entity.ValidForCustomers ?? (object)DBNull.Value)
                , new SqlParameter("@ValidForProducts", entity.ValidForProducts ?? (object)DBNull.Value)
                , new SqlParameter("@ValidForManufacturers", entity.ValidForManufacturers ?? (object)DBNull.Value)
                , new SqlParameter("@ValidForCategories", entity.ValidForCategories ?? (object)DBNull.Value)
                , new SqlParameter("@ValidForSections", entity.ValidForSections ?? (object)DBNull.Value)
                , new SqlParameter("@DisabledByAdministrator", entity.DisabledByAdministrator)
                , new SqlParameter("@ExtensionData", entity.ExtensionData ?? (object)DBNull.Value)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetGiftCard(entity.GiftCardId));
        }