This should work, but might I also suggest you add a TotalPrice
property on the class of your p object.

public decimal TotalPrice
{
  get { return Quantity * Price; }
}

On Sep 15, 3:09 am, "Ernst Naezer" <[EMAIL PROTECTED]> wrote:
> Hi Alex,
>
> I tried to reproduce this issue, but it works fine here;
>
>     [TestFixture]
>     public class NVTests
>     {
>         public class Order
>         {
>             public decimal Price { get; set; }
>             public int Amount { get; set; }
>         }
>
>         [Test]
>         public void Multiply()
>         {
>             var context = new VelocityContext();
>
>             var order = new Order
>                             {
>                                 Amount = 6,
>                                 Price = 12
>                             };
>
>             context.Put("order", order);
>
>             Velocity.Init();
>
>             var sw = new StringWriter();
>
>             Assert.IsTrue(Velocity.Evaluate(context, sw, string.Empty,
> "#set($total = $order.Price * $order.Amount)\r\n$total"));
>             Assert.AreEqual("72", sw.GetStringBuilder().ToString());
>         }
>     }
>
> }
>
> can you try this with your version and otherwise post a failing testcase?
>
> cheers,
>
> On Thu, Sep 11, 2008 at 9:02 PM, Alex <[EMAIL PROTECTED]> wrote:
>
> > here is the problem the multiplication wont happen. I get a zero for
> > the
>
> > <input type="hidden" name="productid$pcount" value="$p.Name"> $p.name</
> > td>
> > <td><input type="text" Name="Quantityid$pcount" value="$p.Quantity"
> > style="width:40px"></td>
>
> > <td><input type="hidden" name="priceid$pcount" value="$p.price">$$
> > {p.Price}</td>
>
> > #set ($totalprice = $p.price * $p.Quantity)
>
> > #set ($subtotal = $subtotal + $totalprice ) <td>${totalprice}</td>
>
> > $totalprice is always zero and subtotal aswell as a result of
> > $totalprice of course.
>
> > P is a class exposed through propertybag. P is for Products.
>
> > I have tried outputting the variables p.price and p.quantity to see if
> > there are values in them and I get results, they just wont get
> > multiplied for some reason I tried covnerting p.price.ToInteger *
> > p.quantity.Tointetger - it didnt error out but it didnt work either. I
> > tried converting the values and assigning them to individual
> > variables, still get 0 (zero)
>
> > Any help would be appreciated.
>
> > Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to