Link to home
Start Free TrialLog in
Avatar of Clare O'Hare
Clare O'Hare

asked on

Booking system - Availabilty check with Ajax to database

I am very new to MVC and I am trying to create a booking system in MVC5. I have set up a my database by EF code first. My booking table is:
     public class Booking
        public Guid BookingId { get; set; }

        public Guid PatientId { get; set; }
        public virtual Patient Patient { get; set; }
        public IEnumerable<SelectListItem> PatientList { get; set; }

        public Guid PracticeId { get; set; }
        public virtual Practice Practice { get; set; }
        public IEnumerable<SelectListItem> PracticeList { get; set; }

        public Guid OpticianId { get; set; }
        public virtual Optician Optician { get; set; }
        public IEnumerable<SelectListItem> OpticiansList { get; set; }

        [Display(Name = "Date")]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
        public DateTime Date { get; set; }

        public Guid? TimeId { get; set; }
        public virtual Time Time { get; set; }
        public IEnumerable<SelectListItem> TimeList { get; set; }
        public bool isAvail { get; set; }

Open in new window

I have used CRUD to make a Create page. Once a booking has been made the isAvail boolean is set to False.
What I am trying to do is create an AJAX query so that once the user selects the practice, optician and date the ajax query checks the database to see if the combination of practice, optician and date does not exist alongside isAvail - false in order to prevent double bookings. The ajax query would then return the available times ie - the time where there is no isAvail = false.

Any help would be greatly appreciated
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial