// GET: ListCustomers
        public ActionResult ListCustomers(string Button)
        {
            DatabaseRequests request = new DatabaseRequests();

            DataTable dt = request.GetCustomersList("all");

            if (Button.Equals("All"))
            {
                dt = request.GetCustomersList("all");
            }
            else if (Button.Equals("Active"))
            {
                dt = request.GetCustomersList("active");
            }
            else if (Button.Equals("Inactive"))
            {
                dt = request.GetCustomersList("inactive");
            }
            else
            {
                return(View("Menu"));
            }

            return(View(dt));
        }
Example #2
0
        // GET: ListCars
        public ActionResult ListAvailableCars()
        {
            DatabaseRequests request = new DatabaseRequests();

            DataTable dt = request.GetCarsList();

            return(View(dt));
        }
Example #3
0
        public ActionResult ListCustomers()
        {
            DatabaseRequests request = new DatabaseRequests();

            DataTable dt = request.GetCustomersList("all");

            return(View(dt));
        }
Example #4
0
        private static async void Start(string[] args)
        {
            await QuartzScheduler.StartScheduler();

            var _databaseRequests = new DatabaseRequests();
            var notifications     = await _databaseRequests.GetNotificationsAsync();

            TriggerNotificationsObserver.SetUpTriggerNotificationObserver(notifications);

            var triggersAndJobs = GetJobs(notifications);
            var TAJForNotificationJobsUpdater = SetUpNotificationJobsUpdater();

            await QuartzScheduler.ScheduleJobs(triggersAndJobs);

            TriggerNotificationsObserver.AddEvent();

            await QuartzScheduler.ScheduleJob(TAJForNotificationJobsUpdater.Item1, TAJForNotificationJobsUpdater.Item2);
        }
Example #5
0
        public ActionResult RegisterNewCarRent(CarRent rent, string Button)
        {
            if (Button.Equals("Submit"))
            {
                Validations                 validation = new Validations();
                DatabaseRequests            request    = new DatabaseRequests();
                Tuple <List <string>, bool> value      = validation.ValidateCarRent(rent.Car.Plate, rent.Reservation.CustomerID.ToString(), rent.StartDate, rent.EndDate, rent.Reservation.Location);

                if (value.Item2)
                {
                    request.AddCarRentToDatabase(rent.Car.Plate, rent.Reservation.CustomerID.ToString(), DateTime.Parse(rent.StartDate), DateTime.Parse(rent.EndDate), rent.Reservation.Location);
                }
                else
                {
                    if (value.Item1[0] != "")
                    {
                        ModelState.AddModelError("Plate", value.Item1[0]);
                    }
                    if (value.Item1[1] != "")
                    {
                        ModelState.AddModelError("CustomerID", value.Item1[1]);
                    }
                    if (value.Item1[2] != "")
                    {
                        ModelState.AddModelError("StartDate", value.Item1[2]);
                    }
                    if (value.Item1[3] != "")
                    {
                        ModelState.AddModelError("EndDate", value.Item1[3]);
                    }
                    if (value.Item1[4] != "")
                    {
                        ModelState.AddModelError("Location", value.Item1[4]);
                    }

                    return(View("RegisterNewCarRent"));
                }
            }

            return(View("Menu"));
        }
Example #6
0
        // GET: UpdateCarRent
        public ActionResult UpdateCarRent(CarRent rent, string Button)
        {
            Validations      validation = new Validations();
            DatabaseRequests request    = new DatabaseRequests();
            Reservation      initialRes = new Reservation();
            string           error      = "";

            if (Button.Equals("Search"))
            {
                if (validation.DateValidation(rent.StartDate) == "")
                {
                    error = request.GetRentForUpdate(rent.Car.Plate, rent.Reservation.CustomerID.ToString(), rent.StartDate, rent);
                }
                else
                {
                    error = request.GetRentForUpdate(rent.Car.Plate, rent.Reservation.CustomerID.ToString(), rent.StartDate, rent);
                }

                if (error == "/")
                {
                    initialRes           = rent.Reservation;
                    initialRes.StartDate = DateTime.Parse(rent.StartDate);
                }
                else if (error.Contains("/"))
                {
                    string[] errors = error.Split('/');

                    if (errors[0] != "")
                    {
                        ModelState.AddModelError("CustomerID", errors[0]);
                    }
                    if (errors[1] != "")
                    {
                        ModelState.AddModelError("Plate", errors[1]);
                    }
                }
                else
                {
                    ModelState.AddModelError("Plate", error);
                }
            }
            else if (Button.Equals("Delete"))
            {
                if (initialRes.Location != "")
                {
                    error = request.DeleteRent(rent.Car.Plate, rent.Reservation.CustomerID.ToString(), Button, initialRes);
                }
            }
            else if (Button.Equals("Update"))
            {
                Tuple <List <string>, bool> value = validation.ValidateCarRent(rent.Car.Plate, rent.Reservation.CustomerID.ToString(), rent.StartDate, rent.EndDate, rent.Reservation.Location);
                if (value.Item2)
                {
                    request.UpdateCarRentInDatabase(rent.Car.Plate, rent.Reservation.CustomerID.ToString(), DateTime.Parse(rent.StartDate), DateTime.Parse(rent.EndDate), rent.Reservation.Location, initialRes);
                }
                else
                {
                    if (value.Item1[0] != "")
                    {
                        ModelState.AddModelError("Plate", value.Item1[0]);
                    }
                    if (value.Item1[1] != "")
                    {
                        ModelState.AddModelError("CustomerID", value.Item1[1]);
                    }
                    if (value.Item1[2] != "")
                    {
                        ModelState.AddModelError("StartDate", value.Item1[2]);
                    }
                    if (value.Item1[3] != "")
                    {
                        ModelState.AddModelError("EndDate", value.Item1[3]);
                    }
                    if (value.Item1[4] != "")
                    {
                        ModelState.AddModelError("Location", value.Item1[4]);
                    }
                }
            }
            else
            {
                return(View("Menu"));
            }

            return(View("UpdateCarRent", rent));
        }