Ejemplo n.º 1
0
 public ActionResult NewAppointment(AppointmentInputViewModel newAppointment, int doctorId)
 {
     _schedulingService.AddAppointment(int.Parse(newAppointment.AssignedPatientId), doctorId,
                                       newAppointment.DateTime, newAppointment.Reason);
     // Redirect to Doctor Schedule
     return(RedirectToAction("DoctorSchedule", "Staff", new { doctorId = doctorId }));
 }
Ejemplo n.º 2
0
        public IActionResult MakeAppointment(AppointmentInputViewModel appointment, string id)
        {
            if (!procedureService.ProcedureExists(id))
            {
                this.ModelState.AddModelError(nameof(appointment.ProcedureName), ErrorConstants.InvalidProcedure);
            }

            appointment.CategoryName = procedureService.GetPrcedureCategoryName(id);

            if (!DateTime.TryParseExact(appointment.Date, "yyyy-MM-dd", null, DateTimeStyles.None, out DateTime appointmentDate))
            {
                this.ModelState.AddModelError(nameof(appointment.Date), ErrorConstants.InvalidDate);
            }

            if (appointmentDate.Date < DateTime.UtcNow.Date)
            {
                this.ModelState.AddModelError(nameof(appointment.Date), ErrorConstants.InvalidDatePassed);
            }

            if (!DateTime.TryParseExact(appointment.Time, "HH:mm", null, DateTimeStyles.None, out DateTime appointmentTime))
            {
                this.ModelState.AddModelError(nameof(appointment.Time), ErrorConstants.InvalidTime);
            }

            if (appointmentTime.TimeOfDay < DateAndTimeConstants.DefaultStartingHours ||
                appointmentTime.TimeOfDay > DateAndTimeConstants.DefaultEndingHours)
            {
                this.ModelState.AddModelError(nameof(appointment.Time), ErrorConstants.InvalidTime);
            }

            if (appointmentDate == DateTime.UtcNow.Date && appointmentTime.TimeOfDay <= DateTime.Now.TimeOfDay)
            {
                this.ModelState.AddModelError(nameof(appointment.Time), ErrorConstants.InvalidTimePassed);
            }

            if (!employeeService.EmployeeExists(appointment.EmployeeId) ||
                !employeeService.EmployeeCanDoProcedure(appointment.EmployeeId, id))
            {
                this.ModelState.AddModelError(nameof(appointment.EmployeeId), ErrorConstants.InvalidEmployee);
            }

            if (!this.ModelState.IsValid)
            {
                appointment.Employees = employeeService
                                        .GetEmployeesForSelect(id)
                                        .ToList();

                return(View(appointment));
            }

            var employeeScheduleId = scheduleService
                                     .GetScheduleIdByEmployeeId(appointment.EmployeeId);

            appointmentService.CreateAppointment(employeeScheduleId, id,
                                                 appointment.ClientName, this.userService.GetUserId(this.User), appointment.Description, appointmentDate, appointmentTime);

            return(Redirect("/Appointments/MyAppointments"));
        }
Ejemplo n.º 3
0
        public IActionResult MakeAppointment(string id)
        {
            if (!procedureService.ProcedureExists(id))
            {
                return(NotFound());
            }

            var appointmentViewModel = new AppointmentInputViewModel
            {
                ProcedureName = procedureService.GetProcedureName(id),
                CategoryName  = procedureService.GetPrcedureCategoryName(id),
                Employees     = employeeService
                                .GetEmployeesForSelect(id)
                                .ToList()
            };

            return(View(appointmentViewModel));
        }