protected override async Task OnInitializedAsync()
        {
            NoteModel       = null;
            OperationStatus = APIOperationStatus.Initial;
            StateHasChanged();

            try
            {
                var response = await HttpClient.GetAsync($"http://localhost:8082/api/history/note/{NoteId}");

                if ((int)response.StatusCode == 200)
                {
                    var stringContent = await response.Content.ReadAsStringAsync();

                    var content = JsonConvert.DeserializeObject <NoteInputModel>(stringContent);

                    NoteModel = content;

                    await JsRuntime.InvokeAsync <object>("InitDataTable", "auditlog-table");
                }

                OperationStatus = APIOperationStatus.GET_Success;
                StateHasChanged();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                OperationStatus = APIOperationStatus.GET_Error;
                StateHasChanged();
            }
        }
Exemplo n.º 2
0
        protected override async Task OnInitializedAsync()
        {
            Status      = APIOperationStatus.Initial;
            Consultants = new List <ConsultantViewModel>();
            var requestUrl =
                Env.IsDevelopment()
                    ? "https://localhost:5009/client-gw/consultant"
                    : "https://localhost:8088/client-gw/consultant";

            try
            {
                Consultants =
                    await ApiRequestService.HandleGetRequest <IEnumerable <ConsultantViewModel> >(requestUrl);

                Status = APIOperationStatus.GET_Success;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Status = APIOperationStatus.GET_Error;
            }

            StateHasChanged();
            await base.OnInitializedAsync();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handle form submission.
        /// </summary>
        /// <returns></returns>
        private async Task HandleSubmit()
        {
            var requestUrl =
                Env.IsDevelopment()
                    ? "https://localhost:5009/client-gw/appointment"
                    : "https://localhost:8088/client-gw/appointment";

            Status = APIOperationStatus.POST_Pending;
            StateHasChanged();

            if (!PatientInApprovedList())
            {
                ToastService.ShowError(
                    "Patient not found. Please ensure that the personal details entered are correct and try again.");
                Status = APIOperationStatus.GET_Success;
                StateHasChanged();
                return;
            }

            if (AppointmentAlreadySubmitted())
            {
                ToastService.ShowError(
                    "There selected consultant already has an appointment scheduled at the selected time.");
                Status = APIOperationStatus.GET_Success;
                StateHasChanged();
                return;
            }

            try
            {
                var dto = CreateDTO();

                var result = await ApiRequestService.HandlePostRequest(requestUrl, dto);

                Status = APIOperationStatus.POST_Success;

                var consultant = ViewModel.ConsultantList.FirstOrDefault(c => c.Id == result.ConsultantId);
                var timeSlot   = ViewModel.TimeSlotList.FirstOrDefault(ts => ts.Id == result.TimeSlotId);

                ToastService.ShowSuccess(
                    $"Appointment with Dr. {consultant?.FirstName} {consultant?.LastName} ({consultant?.Specialty}) on {result.Date:dd/MM/yyyy} from {timeSlot?.StartTime:hh:mm} to {timeSlot?.EndTime:hh:mm} successfully scheduled.");

                NavigationManager.NavigateTo("/");
            }
            catch (Exception e)
            {
                ToastService.ShowError(
                    "There was an error submitting your request. Please ensure that the entered is correct data and retry.");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Component initialization logic.
        /// </summary>
        /// <returns></returns>
        protected override async Task OnInitializedAsync()
        {
            Status = APIOperationStatus.GET_Pending;

            _hubConnection =
                new HubConnectionBuilder()
                .WithUrl(NavigationManager.ToAbsoluteUri("/appointment"))
                .Build();

            _hubConnection.On <AppointmentMessage>("Appointment", msg =>
            {
                ToastService.ShowInfo("Received");

                var consultant =
                    ViewModel.ConsultantList
                    .FirstOrDefault(c => c.Id == msg.ConsultantId);

                var appointment = new AppointmentViewModel
                {
                    Id           = msg.AppointmentId,
                    ConsultantId = msg.ConsultantId,
                    Date         = msg.Date,
                    TimeSlotId   = msg.TimeSlotId
                };

                consultant?.Appointment.Add(appointment);

                EvaluateTimeSlots();

                StateHasChanged();
            });

            await _hubConnection.StartAsync();

            ViewModel = new BookingViewModel();
            FormModel = new BookingFormViewModel();

            ConsultantIsValid = false;
            PatientIsValid    = false;

            PatientEditContext = new EditContext(FormModel.Patient);
            PatientEditContext.OnFieldChanged += HandlePatientEditContextFieldChanged;

            ScheduleEditContext = new EditContext(FormModel.Schedule);
            ScheduleEditContext.OnFieldChanged += HandleConsultantFieldChanged;

            try
            {
                ViewModel = await FetchBookingInfo();

                Status = APIOperationStatus.GET_Success;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Status = APIOperationStatus.GET_Error;
            }

            StateHasChanged();
            await base.OnInitializedAsync();
        }