public bool Add(Appointment model)
 {
     try
     {
         entities.Appointments.Add(model);
         entities.SaveChanges();
         return true;
     }
     catch (Exception x)
     {
         throw x;
     }
 }
 public JsonResult Save(Appointment appointment)
 {
     try
     {
         if (appointment.AppointmentId > 0)
             new AppointmentData().Update(appointment);
         else
             new AppointmentData().Add(appointment);
     }
     catch (Exception x)
     {
     }
     return Json(appointment, JsonRequestBehavior.AllowGet);
 }
 public bool Update(Appointment model)
 {
     try
     {
         Appointment appointment = entities.Appointments.Where(x => x.AppointmentId == model.AppointmentId).SingleOrDefault();
         if (appointment != null)
         {
             entities.Entry(appointment).CurrentValues.SetValues(model);
             entities.SaveChanges();
             return true;
         }
         else
         {
             return false;
         }
     }
     catch (Exception x)
     {
         throw x;
     }
 }