public ActionResult CreateNewRentals(Rental RentalValus) { bool TrueOrFalseMassege = true; string RentalMessges = "Movie rental successfully added"; if (ModelState.IsValid) { bool RentalCustomerExsit = CustomerTableHelper.CustomerExsit(RentalValus.CostomerName); bool RentalMovieExsit = MoviesTableHelper.MovieExsit(RentalValus.MovieName); bool IsTheFilmRented = RentalsTableHelper.IsTheFilmRented(RentalValus.MovieName); if (RentalCustomerExsit) { if (RentalMovieExsit) { if (IsTheFilmRented) { TrueOrFalseMassege = false; RentalMessges = "The film is rented"; } else { RentalsTableHelper.AddRentals(RentalValus.CostomerName, RentalValus.MovieName); TrueOrFalseMassege = true; RentalMessges = "Movie rental successfully added"; } } else { TrueOrFalseMassege = false; RentalMessges = "Movie not Exsit"; } } else { TrueOrFalseMassege = false; RentalMessges = "Customer not Exsit"; if (RentalMovieExsit != true) { RentalMessges += " Movie not found"; } } } else { TrueOrFalseMassege = false; ViewBag.succass = "succass"; RentalMessges = "Movie rental successfully added"; } var obj = new { RentalMessge = RentalMessges, MassegeBool = TrueOrFalseMassege }; return(Json(obj, JsonRequestBehavior.AllowGet)); }
public ActionResult CustomersSave(Customer CustomerValus) { ViewBag.customerName = ""; ViewBag.customerCategory = ""; ViewBag.customerAge = ""; bool CustomerExsitValid = CustomerTableHelper.CustomerExsit(CustomerValus.CustomersName); if (ModelState.IsValid) { if (CustomerExsitValid) { ViewBag.messageExsit = "Inputs Exsit"; ViewBag.customerName = "notvalid"; return(View("CustomersNew", CustomerValus)); } else { CustomerTableHelper.AddCustome(CustomerValus.CustomersName, CustomerValus.CustomersSubscription, CustomerValus.CustomersAge); return(RedirectToAction("CustomersIndex")); } } else { if (CustomerValus.CustomersName == null) { ViewBag.customerName = "notvalid"; } if (CustomerValus.CustomersSubscription == null) { ViewBag.customerSubscription = "notvalid"; } if (CustomerValus.CustomersAge == 0) { ViewBag.customerAge = "notvalid"; } return(View("CustomersNew", CustomerValus)); } }
// GET: Customers public ActionResult CustomersIndex() { List <Customer> list = CustomerTableHelper.GetAllCustomersList(); return(View(list)); }