コード例 #1
0
        public ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            try
            {
                AppointmentViewModelFull appointmentViewModel = (AppointmentViewModelFull)DHXEventsHelper.Bind(typeof(AppointmentViewModelFull), actionValues);

                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    int patientID = int.Parse(sessionStateManger.getSecyrtaryActivePatinet(User.Identity.GetUserId()));
                    appointmentViewModel.ClinicID  = sessionStateManger.getClinecIDForCurrentSecurtary(User.Identity.GetUserId());
                    appointmentViewModel.PatientID = patientID;
                    appointmentViewModel.Status    = appointmentViewModel.Status;
                    appointmentViewModel.text      = "DR:" + doctorRepository.getDoctorNameByID(appointmentViewModel.DoctorID) + " Patient:" + patientRepository.getPatientNameByID(patientID);
                    action.TargetId = appointmentRepository.AddNewAppointment(appointmentViewModel);
                    break;

                case DataActionTypes.Delete:
                    appointmentRepository.deleteAppointment(appointmentViewModel.id);
                    break;

                default:
                    appointmentRepository.alterAppointment(appointmentViewModel);
                    break;
                }
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            return(Content(new AjaxSaveResponse(action), "text/xml"));
        }
コード例 #2
0
        public bool alterAppointment(AppointmentViewModelFull appointment)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Appointment appointmentEntity = ctx.Appointments.Find(appointment.id);

                if (appointmentEntity == null)
                {
                    return(false);
                }

                appointmentEntity.ClinicID   = appointment.ClinicID;
                appointmentEntity.DoctorID   = appointment.DoctorID;
                appointmentEntity.PatientID  = appointment.PatientID;
                appointmentEntity.Reason     = appointment.Reason;
                appointmentEntity.Status     = appointment.Status;
                appointmentEntity.Start_date = appointment.start_date;
                appointmentEntity.End_date   = appointment.end_date;
                appointmentEntity.Text       = appointment.text;

                ctx.Entry(appointmentEntity).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
コード例 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            AppointmentFormTemplateContainer container = (AppointmentFormTemplateContainer)Parent;

            if (cbPatients.SelectedItem != null || cbDoctors.SelectedItem != null || cbClinics.SelectedItem != null || cbStatus.SelectedItem != null)
            {
                if (container.IsNewAppointment)
                {
                    AppointmentViewModelFull app = new AppointmentViewModelFull()
                    {
                        ClinicID   = int.Parse(cbClinics.SelectedItem.Value.ToString()),
                        DoctorID   = int.Parse(cbDoctors.SelectedItem.Value.ToString()),
                        PatientID  = int.Parse(cbPatients.SelectedItem.Value.ToString()),
                        start_date = edtStartDate.Date,
                        end_date   = edtEndDate.Date,
                        Reason     = string.Empty,
                        Status     = cbStatus.SelectedItem.Text,
                        text       = tbDescription.Text
                    };
                    AppointmentRepository apprep = new AppointmentRepository();
                    apprep.AddNewAppointment(app);
                }


                else
                {
                    AppointmentViewModelFull app = new AppointmentViewModelFull()
                    {
                        id         = int.Parse(container.Appointment.Id.ToString()),
                        ClinicID   = int.Parse(cbClinics.SelectedItem.Value.ToString()),
                        DoctorID   = int.Parse(cbDoctors.SelectedItem.Value.ToString()),
                        PatientID  = int.Parse(cbPatients.SelectedItem.Value.ToString()),
                        start_date = edtStartDate.Date,
                        end_date   = edtEndDate.Date,
                        Reason     = string.Empty,
                        Status     = cbStatus.SelectedItem.Text,
                        text       = tbDescription.Text
                    };
                    AppointmentRepository apprep = new AppointmentRepository();
                    apprep.alterAppointment(app);
                }
                Response.Redirect("~/Appoiment/Appoiments.aspx");
            }
            else
            {
                //warining
            }
        }
コード例 #4
0
        public int AddNewAppointment(AppointmentViewModelFull appointment)
        {
            int appointmentID = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                Appointment appointmentEntity = ctx.Appointments.Create();
                appointmentEntity.ClinicID   = appointment.ClinicID;
                appointmentEntity.DoctorID   = appointment.DoctorID;
                appointmentEntity.PatientID  = appointment.PatientID;
                appointmentEntity.Reason     = appointment.Reason;
                appointmentEntity.Status     = appointment.Status;
                appointmentEntity.Start_date = appointment.start_date;
                appointmentEntity.End_date   = appointment.end_date;
                appointmentEntity.Text       = appointment.text;

                ctx.Appointments.Add(appointmentEntity);
                ctx.SaveChanges();
                appointmentID = appointmentEntity.AppointmentID;
            }
            return(appointmentID);
        }