Click here to Skip to main content
15,916,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..
SQL
<pre lang="c#">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.
    }

The error being:

Line 33: </td>
Line 34: <td>
Line 35: @Html.DisplayFor(modelItem => item.OnHire)
Line 36: </td>
Line 37: <td>
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..

XML
<pre lang="sql">
<pre lang="c#">

  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;
       // }

    }
}
&lt;/pre&gt;</pre>

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

1 solution

I wouldn't use a Bool? if you really need to use a Bool? then you need to account for a NULL
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900