asp.net mvc - true instead of True (C#) -


the goal

return true instead of true controller view.

the problem

i'm storing variable boolean indicates if product exists or not in shopping cart/summary.

to realize this, i'm doing follow:

[...] isadded = sessionstore.checkexistanceonsummary(product.productid) [...] 

but, when show value of isadded on view, return true or false — , javascript expecting true or false.

what need send true or false instead of way c# sending.

what i've tried

i tried change above's code fragment this:

isadded = (sessionstore.checkexistanceonsummary(product.productid) ?      "true" :      "false") 

but debugger returns me following error:

error 5 cannot implicitly convert type 'string' 'bool'

a few lines of code

the implementation of checkexistanteonsummary is:

public bool checkexistanceonsummary(nullable<int> productid) {     list<products> productslist =          (list<products>)session[summarysessionindex];      if (productslist.where         (product => product.id == (int)productid).firstordefault() == null)         return false;     else         return true; } 

duplicated?

i read this topic, not helped me.

as boolean (bool), values "true" or "false". if want represent these differently when converted string, can following in view:

@model.isadded.tostring().tolower() 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -