コード例 #1
0
        public async Task <ActionResult <bool> > CreateAppointment(AppointmentEntity appointmentToCreate)
        {
            var flag = await _appointmentService.CreateAppointment(appointmentToCreate);

            //System.Diagnostics.Debug.WriteLine(users);
            return(Ok(flag));
        }
コード例 #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"));
        }
コード例 #3
0
        public async Task <IActionResult> CreateAppointment([FromBody] AppointmentCreateModel model)
        {
            var result = await _appointmentService.CreateAppointment(_mapper.Map <AppointmentDTO>(model));

            return(CreatedAtAction(nameof(GetAppointmentById), new
            {
                id = result.Id
            }, result));
        }
コード例 #4
0
        public async Task <IActionResult> PostNewAppointment([FromBody] AppointmentDTO appointmentDTO)
        {
            Appointment newAppointment = appointmentService.CreateAppointment(Request, appointmentDTO);

            if (newAppointment != null)
            {
                await userService.SendMessages(newAppointment);

                return(Created("", new { message = "Success" }));
            }
            else
            {
                return(BadRequest(new { message = "Your request is not valid" }));
            }
        }
コード例 #5
0
        public ActionResult CreateAppointment(CreateAppointmentViewModel model)
        {
            try
            {
                var timeZone = Request.Cookies["TimeZone"].Value;
                var authInfo = (AuthInfo)Session["auth_info"];
                if (authInfo == null)
                {
                    return(Json(new KeyValueResult(false, "Your session has expired. Please signin again."), JsonRequestBehavior.AllowGet));
                }
                var dateTimeExpected = model.ExpectedDate + " " + model.ExpectedTime;
                var dateExpected     = Utils.StringToDateTime(dateTimeExpected);
                var appointment      = new CreateUpdateAppointmentModel
                {
                    ClinicId         = authInfo.CurrentSelectedClinic.ClinicId,
                    PatientId        = model.PatientId,
                    DoctorId         = model.DoctorId,
                    DoctorName       = model.DoctorName,
                    ClinicName       = authInfo.CurrentSelectedClinic.ClinicName,
                    ClinicPhone      = authInfo.CurrentSelectedClinic.Phone,
                    ExpectedDuration = int.Parse(model.Duration),
                    CarerFirstName   = model.OtherFirstName,
                    CarerLastName    = model.OtherLastName,
                    IsCarer          = model.IsCarer ? 1: 0,
                    IsNewPatient     = model.IsNewPatient,
                    Patient          = new PatientCreateAppointmentModel
                    {
                        FirstName = model.FirstName,
                        LastName  = model.LastName,
                        Phone     = model.Phone,
                        Email     = model.Email
                    },
                    ExpectedStartDateTime = Utils.ToUTCTimeSpan(dateExpected, timeZone),
                    MeetingUri            = model.SipUriMeeting,
                    JoinMettingUrl        = model.UrlJoinMeeting
                };

                _appointmentService.CreateAppointment(appointment);
                return(Json(new KeyValueResult(true, "Welio appointment successfully created."), JsonRequestBehavior.AllowGet));
            }
            catch (ApiException ex)
            {
                return(Json(new KeyValueResult(false, ex.Message), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #6
0
        public Response Post(Appointment appointment)
        {
            Response response = new Response()
            {
                Success = true
            };

            try
            {
                appointmentService.CreateAppointment(appointment);
            }
            catch (Exception exc)
            {
                response.Success      = false;
                response.ErrorCode    = ((int)ErrorResponse.ServerError).ToString();
                response.ErrorMessage = exc.Message;
            }

            return(response);
        }
コード例 #7
0
        public async Task <ActionResult <Appointment> > CreateAppointment(a.AppointmentResource appointment)
        {
            var appointmentResuource = _mapper.Map <a.AppointmentResource, Appointment>(appointment);
            var result = await _appointmentService.CreateAppointment(appointmentResuource);

            //if (result != null)
            //{
            //    TransactionSetup transactionSetup = new TransactionSetup();
            //    transactionSetup.TransactionStatus = Status.Start;
            //    transactionSetup.EventRaised = true;
            //    transactionSetup.AppoitmentId = result.Id;
            //    await _logService.CreateLog(transactionSetup);
            //    if (!_amqService.SendEvent(transactionSetup, EVENT_NAME_STATUS))
            //    {
            //        transactionSetup.EventRaised = false;
            //        var id = new Guid(result.Id.ToString());
            //        var log = await _logService.GetLogByAppoitmentId(id);
            //        await _logService.UpdateLog(transactionSetup, log);
            //    }

            //}

            return(Ok(result));
        }
コード例 #8
0
        public async Task <IHttpActionResult> CreateAppointment(AppointmentProjection appointment)
        {
            var createdAppointment = await _appointmentService.CreateAppointment(appointment);

            return(Ok(appointment));
        }
コード例 #9
0
 public ActionResult Create([FromBody] Appointment appointment) => Ok(_appointment.CreateAppointment(appointment));