示例#1
0
        /// <summary>
        /// Translates the specified original model.
        /// </summary>
        /// <param name="originalModel">The original model.</param>
        /// <param name="viewModel">The view model.</param>
        /// <returns></returns>
        /// <inheritdoc />
        public AppointmentModel Translate(
            AppointmentModel originalModel,
            UpdateAppointmentViewModel viewModel)
        {
            DateTime now = TimeZone.CurrentTimeZone.ToLocalTime(DateTime.Now);

            DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(viewModel.StartTime);

            AppointmentModel model = new AppointmentModel
            {
                Id                = originalModel.Id,
                CustomerId        = originalModel.CustomerId,
                ServiceProviderId = originalModel.ServiceProviderId,
                CreatedTime       = originalModel.CreatedTime,
                CreatedUser       = originalModel.CreatedUser,
                LasteUpdatedTime  = now,
                StartTime         = startTime,
                Duration          = viewModel.Duration,
                Location          = viewModel.Location,
                Description       = viewModel.Description,
                PaymentId         = viewModel.PaymentId,
                InvoiceId         = originalModel.InvoiceId
            };

            return(model);
        }
示例#2
0
        IActionResult RemoveProcedureFromAppointment(UpdateAppointmentViewModel model, int appointmentId, int procedureId)
        {
            UpdateAppointmentViewModel newModel = new UpdateAppointmentViewModel();
            var appointment = repository.GetAppointmentById(appointmentId);
            var procedure   = repository.GetProcedureById(procedureId);

            if (appointment == null || procedure == null)
            {
                TempData["FormError"] = "There was an error removing procedure to appointment";
            }
            else
            {
                appointment.Bill.Procedures.Remove(procedure);
                try
                {
                    repository.SaveAll();
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, $"Could not save removal of procedure from appointment, {ex}");
                }
            }

            var procedures = repository.GetAllProcedures();

            newModel.Procedures  = mapper.Map <IEnumerable <Procedure>, IEnumerable <ProcedureViewModel> >(procedures).ToList();
            newModel.Appointment = mapper.Map <Appointment, AppointmentViewModel>(appointment);
            newModel.PatientId   = model.PatientId;

            return(View(newModel));
        }
示例#3
0
        public IActionResult UpdateAppointment(UpdateAppointmentViewModel model, int appointmentId, int procedureId, string AppointmentSubmit)
        {
            switch (AppointmentSubmit)
            {
            case "Add To Appointment":
                return(AddProcedureToAppointment(model, appointmentId, procedureId));

            case "Remove":
                return(RemoveProcedureFromAppointment(model, appointmentId, procedureId));

            case "Back To Patient":
                var patient = repository.GetPatientById(model.PatientId);
                if (patient != null)
                {
                    return(RedirectToAction("PatientInfo", new { id = patient.Id }));
                }
                break;
            }

            return(View(new { id = appointmentId, patientId = model.PatientId }));
        }
示例#4
0
        public ActionResult UpdateAppointment(UpdateAppointmentViewModel viewModel)
        {
            LoggingService.Info(GetType());

            if (rulesEngineService.IsCustomerAppointmentsEnabled() == false)
            {
                ThrowAccessDeniedException("No Access to update appointment");
            }

            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            string nextUrl = appointmentsManager.UpdateAppointment(
                UmbracoContext,
                viewModel,
                Members.CurrentUserName);

            return(Json(nextUrl));
        }
示例#5
0
        public IActionResult UpdateAppointment(int id, int patientId)
        {
            if (!CheckAuthorization())
            {
                return(AuthorizeSendBack());
            }

            UpdateAppointmentViewModel model = new UpdateAppointmentViewModel();
            var appointment = repository.GetAppointmentById(id);

            if (appointment != null)
            {
                model.Appointment = mapper.Map <Appointment, AppointmentViewModel>(appointment);
            }

            var procedures = repository.GetAllProcedures();

            model.Procedures = mapper.Map <IEnumerable <Procedure>, IEnumerable <ProcedureViewModel> >(procedures).ToList();
            model.PatientId  = patientId;

            return(View(model));
        }
示例#6
0
        /// <summary>
        /// Updates the appointment.
        /// </summary>
        /// <param name="umbracoContext">The umbraco context.</param>
        /// <param name="viewModel">The view model.</param>
        /// <param name="lastUpdatedUser">The last updated user.</param>
        /// <returns></returns>
        /// <inheritdoc />
        public string UpdateAppointment(
            UmbracoContext umbracoContext,
            UpdateAppointmentViewModel viewModel,
            string lastUpdatedUser)
        {
            loggingService.Info(GetType(), "Start");

            AppointmentSettingsModel appointmentSettingsModel = appointmentsProvider.GetAppointmentsModel(umbracoContext);

            AppointmentModel originalModel = databaseProvider.GetAppointment(Convert.ToInt32(viewModel.Id), GetCustomerId(umbracoContext));

            AppointmentModel appointmentModel = appointmentTranslator.Translate(originalModel, viewModel);

            appointmentModel.LastedUpdatedUser = lastUpdatedUser;

            loggingService.Info(GetType(), "Database Integration");

            databaseProvider.UpdateAppointment(appointmentModel);

            //// now update the attendees
            if (viewModel.Attendees != null)
            {
                UpdateAppointmentAttendees(appointmentModel.Id, viewModel.Attendees);
            }

            if (appointmentSettingsModel.GoogleCalendarIntegration)
            {
                loggingService.Info(GetType(), "Google Calendar Integration");
            }

            if (appointmentSettingsModel.IcalIntegration &&
                string.IsNullOrEmpty(appointmentSettingsModel.IcalUpdateEmailTemplate) == false)
            {
                Dictionary <string, string> dictionary = new Dictionary <string, string>
                {
                    { "AppointmentId", viewModel.Id.ToString() },
                    { "AppointmentStartTime", viewModel.StartTime.ToLongTimeString() },
                    { "AppointmentDuration", viewModel.Duration.ToString(CultureInfo.InvariantCulture) },
                    { "AppointmentLocation", viewModel.Location },
                    { "AppointmentDescription", viewModel.Description }
                };

                ICalAppointmentModel iCalModel = databaseProvider.GetIcalAppointment(viewModel.Id);

                ICalAppointmentModel iCalAppointmentModel = iCalendarService.GetICalAppoinment(
                    appointmentModel,
                    iCalModel.Guid,
                    iCalModel.Sequence + 1);

                Attachment attachment = Attachment.CreateAttachmentFromString(
                    iCalAppointmentModel.SerializedString,
                    iCalAppointmentModel.ContentType);

                mailProvider.SendEmail(
                    umbracoContext,
                    appointmentSettingsModel.IcalUpdateEmailTemplate,
                    appointmentSettingsModel.IcalEmailAddress,
                    attachment,
                    dictionary);

                if (appointmentSettingsModel.IcalSendToAttendees)
                {
                    if (appointmentModel.Attendees != null)
                    {
                        foreach (AppointmentAttendeeModel attendeeModel in appointmentModel.Attendees)
                        {
                            mailProvider.SendEmail(
                                umbracoContext,
                                appointmentSettingsModel.IcalUpdateEmailTemplate,
                                attendeeModel.EmailAddress,
                                attachment,
                                dictionary);
                        }
                    }
                }
            }

            //// TODO : this needs changing!!
            return("/customer/appointments");
        }