Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC3
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)?
 
HttpPost]
        public ActionResult Create(Rental rentals)
        {
            try
            {
                // TODO: Add insert logic here
                _entities.AddToRentals(rentals);
                _entities.SaveChanges();
 
                Movie mov = new Movie();
 
                if (rentals.OnHire)
                {
                    mov.OnHire = true;
                }
                else
                {
                    mov.OnHire = false;
                }
      
                return RedirectToAction("Index");
            }
            catch
            {
                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?
 
Thanks
Posted 21-Oct-12 13:20pm
Comments
xnaLearner at 21-Oct-12 19:41pm
   
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 bool...is this possible without using actual sql coding?...please see below

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 bool...is this possible without using actual sql coding?...please see below
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 406
1 /\jmot 180
2 Suraj Sahoo | Coding Passion 170
3 BillWoodruff 159
4 Afzaal Ahmad Zeeshan 154
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 21 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100