change bool on a model class MVC

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hey guys...So im using mvc3 to create a database website for a rental system.

in my rental.cs in my model folder it goes like...
<pre class="prettyprint public class Rental
{
public int RentalID { get; set; }

public int CustomerID { get; set; }

public int MovieID { get; set; }

public bool? OnHire { get; set; }
// public static bool test; //On another note i had to take out the static in public statick bool? onhire as it threw an error when I tried to load the rentals page.
} [/code]
The error being:
<pre>Line 33: </td>
Line 34: <td>
<span style="color:red Line 35: @Html.DisplayFor(modelItem => item.OnHire)
Line 36: </td>
Line 37: <td>[/code]
So here I was trying to use a static bool, which will allow me to use it in a different class.
Then in the movies class I was trying to say when the rental.OnHire = true, the movie.onHire will also be true.
The idea being when the user rents out a copy they change the onHire to yes on the rental page, which will change the movie on the movies page from false to true for Onhire
<pre class="prettyprint public class Movie
{
public int MovieID { get; set; }

public string Title { get; set; }

public string Producer { get; set; }

public string Genre { get; set; }

public bool? OnHire { get; set; }

// if (Rental.Onhire)
//{
//OnHire = true;
// }

}
}[/code]
<br/>

Although it wasnt picking up the bool. Could someone please advise where I am going wrong. Am I going about this the right way?
<br/>


View the full article
 
Back
Top