This project is read-only.

MVC3 bools for tables + search

Oct 21, 2012 at 11:18 PM

Attempting to database driven website for video rentals

So I have two tables in my database (movie, and rental), 
I have a column set in each table 'OnHire' which has the data value of 'bit'
with NULL values selected.

So I have all the CRUD features working but...

When the user creates a new rental record in the rental table and turns 'OnHire' to true
I am trying to use a bool which will then turn the 'OnHire' in movies to true.

Allowing the user to know by looking at the movies table whether it is on hire or not
it is telling me i cant convert a type bool? to bool, a conversion exists(are you missing a cat)?

        public ActionResult Create(Rental rentals)
                // TODO: Add insert logic here

                Movie mov = new Movie();

                if (rentals.OnHire)
                    mov.OnHire = true;
                    mov.OnHire = false;
                return RedirectToAction("Index");
                return View();

Then I am probably pushing my luck here but if that is successfull I was going to do the opposite and throw an error message if the user tries to hire out a video already on hire

                if (mov.OnHire)
                    //error message

 Any suggestions?

Also on completion of the CRUD for database I was looking to implement a search feature?

Any ideas on any tutorials guys?


Oct 22, 2012 at 12:39 AM

I am trying to use an if statement inside the create function of CRUD. and by making a reference to the record in the DB i want to update a record using a this possible without using actual sql coding?...please see below

Oct 22, 2012 at 5:20 PM

Hey xna4life. Unfortunately, this question isn't really within the scope of the openforum project. If you're looking for a forum to post general programming questions in, I would HIGHLY recommend It's full of people who would be willing and able to quickly help you with these issues :)