コード例 #1
0
 public bool CreateAppointment(Appointment appointment)
 {
     //service.Resource = "api/appointments/CreateAppointment";
     //service.CreateResult(appointment);
     service.Resource = "api/appointments";
     service.CreateResult(appointment);
     return true;
 }
コード例 #2
0
        public bool UpdateAppointment(Appointment appointment)
        {
            service.Resource = "api/appointments";
            service.UpdateResult(appointment);
            //Appointment appointment = context.Appointments.Find(appointmentId);
            //appointment.PatientId = appointment.PatientId;
            //appointment.DoctorId = appointment.DoctorId;
            //appointment.AppointmentDate = appointment.DoctorId
            //context.SaveChanges();

            return true;
        }
コード例 #3
0
        public ActionResult Create(AppointmentsCreateViewModel appointmentsVM)
        {
            Appointment appointment = new Appointment();

            if (User.IsInRole("Doctor"))
            {
                appointmentsVM.doctorAppointment.DoctorId = db.Doctors.Where(r => r.Name == User.Identity.Name).Select(r => r.DoctorId).FirstOrDefault();
                appointment = appointmentsVM.doctorAppointment;
            }

            else if (User.IsInRole("Patient"))
            {
                if (appointmentsVM.currentTab == 1)
                {
                    appointmentsVM.tab1Appointment.PatientId = db.Patients.Where(r => r.Name == User.Identity.Name).Select(r => r.PatientId).FirstOrDefault();
                    appointment = appointmentsVM.tab1Appointment;
                    RemoveModelStateKeyByTab("tab2");
                }
                else if (appointmentsVM.currentTab == 2)
                {
                    appointmentsVM.tab2Appointment.PatientId = db.Patients.Where(r => r.Name == User.Identity.Name).Select(r => r.PatientId).FirstOrDefault();
                    appointment = appointmentsVM.tab2Appointment;
                    RemoveModelStateKeyByTab("tab1");
                }
            }
            else if (User.IsInRole("Admin"))
            {
                if (appointmentsVM.currentTab == 1)
                {
                    appointment = appointmentsVM.tab1Appointment;
                    RemoveModelStateKeyByTab("tab2");
                }
                else if (appointmentsVM.currentTab == 2)
                {
                    appointment = appointmentsVM.tab2Appointment;
                    RemoveModelStateKeyByTab("tab1");
                }
            }

            if (ModelState.IsValid)
            {
                channelManager.CreateAppointment(appointment);
                return RedirectToAction("index");
            }

            ViewBag.tab1Appointment.DoctorId = new SelectList(db.Doctors, "DoctorId", "Name", appointmentsVM.tab1Appointment.DoctorId);
            ViewBag.tab1Appointment.PatientId = new SelectList(db.Patients, "PatientId", "Name", appointmentsVM.tab1Appointment.PatientId);
            ViewBag.tab2Appointment.DoctorId = new SelectList(db.Doctors, "DoctorId", "Name", appointmentsVM.tab2Appointment.DoctorId);
            ViewBag.tab2Appointment.PatientId = new SelectList(db.Patients, "PatientId", "Name", appointmentsVM.tab2Appointment.PatientId);
            return View(appointmentsVM);
        }
コード例 #4
0
 public ActionResult Edit(Appointment Appointment)
 {
     if (ModelState.IsValid)
     {
         service.Resource = "api/appointments";
         service.UpdateResult(Appointment);
         //var result = channelManager.UpdateAppointment(Appointment);
         //db.Entry(Appointment).State = EntityState.Modified;
         //db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.DoctorId = new SelectList(db.Doctors, "DoctorId", "Name", Appointment.DoctorId);
     ViewBag.SpecializationId = new SelectList(db.Specializations, "SpecializationId", "SpecializationName", 0);
     ViewBag.PatientId = new SelectList(db.Patients, "PatientId", "Name", Appointment.PatientId);
     return View(Appointment);
 }