Example #1
0
        public ActionResult RegisterNewCarRent(Models.NewRent model)
        {
            SqlConnection con = Models.DatabaseConnection.Conecting_to_database();

            if (ModelState.IsValid)
            {
                string carId = Models.RegisterNewRent.CarID_from_plate(model.Plate, con);
                if (carId != "" && Models.RegisterNewRent.DataValidation(model.Start) && RegisterNewRent.DataValidation(model.end))
                {
                    if (RegisterNewRent.ClientExist(con, int.Parse(model.ClientID)) && RegisterNewRent.CarAvailable(con, carId, DateTime.Parse(model.Start), DateTime.Parse(model.end)) && RegisterNewRent.CheckDate(DateTime.Parse(model.Start), DateTime.Parse(model.end)))

                    {
                        RegisterNewRent.Register_car_rent(carId, model.ClientID, "1", model.Start, model.end, model.City, RegisterNewRent.Randome_cupon(con), con);
                        return(RedirectToAction("SignIn"));
                    }
                }
            }
            return(View());
        }
Example #2
0
        public ActionResult UpdateCarRent(Models.NewRent model)
        {
            SqlConnection con = DatabaseConnection.Conecting_to_database();

            if (ModelState.IsValid)
            {
                string   carId = RegisterNewRent.CarID_from_plate(model.Plate, con);
                DateTime start = DateTime.Parse(model.Start);
                DateTime end   = DateTime.Parse(model.end);
                if (carId != "" && Models.RegisterNewRent.DataValidation(model.Start) && RegisterNewRent.DataValidation(model.end))
                {
                    if (RegisterNewRent.CarAvailable(con, carId, start, end) && RegisterNewRent.ClientExist(con, int.Parse(model.ClientID)) && RegisterNewRent.CheckDate(start, end))
                    {
                        Update_Rent.update_rent(con, model.ClientID, carId, start.ToString(), end.ToString(), model.City);
                        return(RedirectToAction("SignIn"));
                    }
                }
            }
            return(View());
        }