We help IT Professionals succeed at work.
Get Started

Booking system - Availabilty check with Ajax to database

Clare O'Hare
Clare O'Hare asked
on
178 Views
Last Modified: 2016-07-04
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
    {
       [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public Guid BookingId { get; set; }

        [ForeignKey("Patient")]
        public Guid PatientId { get; set; }
        public virtual Patient Patient { get; set; }
        public IEnumerable<SelectListItem> PatientList { get; set; }

        [ForeignKey("Practice")]
        public Guid PracticeId { get; set; }
        public virtual Practice Practice { get; set; }
        public IEnumerable<SelectListItem> PracticeList { get; set; }

        [ForeignKey("Optician")]
        public Guid OpticianId { get; set; }
        public virtual Optician Optician { get; set; }
        public IEnumerable<SelectListItem> OpticiansList { get; set; }

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

        [ForeignKey("Time")]
        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
Thanks
Comment
Watch Question
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE