예제 #1
0
        private async Task BuscarAsync(string busca)
        {
            if (string.IsNullOrEmpty(busca) || busca.Length < 8)
            {
                ToastService.ShowInfo($"O código {busca} do exame está inválido!");
                return;
            }

            _carregando = true;
            StateHasChanged();

            _dto = await HttpServico.GetPorCodigoAsync(busca);

            if (_dto == null)
            {
                ToastService.ShowInfo($"Nenhum exame localizado com o código {busca}");
                _dto        = new ExameDTO();
                _carregando = false;
                StateHasChanged();
                return;
            }

            Id = _dto.Id;

            _carregando = false;
            StateHasChanged();
        }
예제 #2
0
        protected async override Task <bool> Salvar(EditContext editContext)
        {
            if (!_desabilitaBotoes && !_dto.ReceitaMedicamentos.Any(_ => _.Ativo))
            {
                ToastService.ShowInfo("Você precisa selecionar adicionar um ou mais medicamentos!");
                return(false);
            }

            var result = true;

            if (!_desabilitaBotoes)
            {
                result = await base.Salvar(editContext);
            }

            if (result)
            {
                if (string.IsNullOrEmpty(_dto?.Observacao?.Trim()))
                {
                    ToastService.ShowInfo("Não existe nenhuma informação para ser impressa!");
                    return(false);
                }

                await JSRuntime.PrintContentAsync("receita-observacao");
            }

            return(result);
        }
        public void Process(OperationResult model)
        {
            Messages.Clear();
            foreach (var errorMessage in model.Errors)
            {
                switch (errorMessage.Code)
                {
                case "Toast.Info":
                    ToastService.ShowInfo(errorMessage.Text);
                    break;

                case "Toast.Success":
                    ToastService.ShowSuccess(errorMessage.Text);
                    break;

                case "Toast.Error":
                    ToastService.ShowError(errorMessage.Text);
                    break;

                case "Toast.Warning":
                    ToastService.ShowWarning(errorMessage.Text);
                    break;

                default:
                    Messages.Add(errorMessage);
                    break;
                }
            }
            Show = true;
            StateHasChanged();
        }
        public async Task NotifySaveClicked()
        {
            if (await GeneralSettings.Save() && await RecipientSettings.Save())
            {
                await JSRuntime.InvokeVoidAsync("scrollIntoView", "settings-top");

                ToastService.ShowInfo("Settings saved");
            }
        }
        protected async Task LoadSample()
        {
            Config = JsonSerializer.Deserialize <Models.OptimizerConfiguration>(Resource.OptimizationConfigSample);

            StoreConfig(Config);

            Config.FitnessTypeName = Config.FitnessTypeName.Split('.').LastOrDefault();
            ToggleFitness();
            Json = Resource.OptimizationConfigSample;
            ToastService.ShowInfo("Sample was loaded");
        }
예제 #6
0
        protected async void OnRemoveFridge()
        {
            var wasRemoveSuccessful = await FridgeDataService.DeleteFridge(Fridge.HouseholdId, Fridge.FridgeId);

            if (wasRemoveSuccessful)
            {
                NavigationManager.NavigateTo($"household/{Fridge.HouseholdId}");
                ToastService.ShowInfo($"Removed {Fridge.Name}");
            }
            else
            {
                ToastService.ShowError($"Failed to remove {Fridge.Name}", "Delete Failed");
            }
        }
예제 #7
0
        protected async Task OnRemoveHousehold()
        {
            var removeSuccessful = await HouseholdDataService.DeleteHousehold(Household.HouseholdId);

            if (removeSuccessful)
            {
                NavigationManager.NavigateTo("/");
                ToastService.ShowInfo($"Successfully removed {Household.Name}");
            }
            else
            {
                ToastService.ShowError($"Could not remove {Household.Name}", "Delete failed");
            }
        }
예제 #8
0
        protected async Task DeleteFridgeItem(FridgeItem fridgeItem)
        {
            var wasRemoveSuccessful = await FridgeDataService.DeleteFridgeItem(Fridge.HouseholdId, Fridge.FridgeId, fridgeItem.FridgeItemId);

            if (wasRemoveSuccessful)
            {
                FridgeItems.Remove(fridgeItem);
                StateHasChanged();
                ToastService.ShowInfo($"Successfully removed {fridgeItem.Name}");
            }
            else
            {
                ToastService.ShowError($"Could not remove {fridgeItem.Name}", "Delete Failed");
            }
        }
예제 #9
0
        public Task HandleAsync(OnlineStateChangedEvent message, CancellationToken cancellationToken)
        {
            IsOnline = message.IsOnline;
            StateHasChanged();

            if (IsOnline)
            {
                ToastService.ShowSuccess("Connection to Backend Established", "Online");
            }
            else
            {
                ToastService.ShowInfo("No Connection to Backend possible", "Offline");
            }

            return(Task.CompletedTask);
        }
예제 #10
0
        protected async Task DeleteFridge(Fridge fridge)
        {
            var wasRemoveSuccessfull = await FridgeDataService.DeleteFridge(Household.HouseholdId, fridge.FridgeId);

            if (wasRemoveSuccessfull)
            {
                Fridges.Remove(fridge);
                StateHasChanged();

                ToastService.ShowInfo($"Removed {fridge.Name}");
            }
            else
            {
                ToastService.ShowError($"Failed to remove {fridge.Name}", "Delete Failed");
            }
        }
        private async Task BuscarAsync()
        {
            if (string.IsNullOrEmpty(_busca))
            {
                return;
            }

            var consulta = await ConsultasServico.GetPorCodigoAsync(_busca);

            if (consulta == null)
            {
                ToastService.ShowInfo($"Nenhuma consulta encontrada com o código {_busca}");
                return;
            }

            await CalendarRenderAsync(consulta.Data, consulta.Data, _busca, "listWeek", consulta.Data);
        }
        private async Task AgendarConsultaAsync()
        {
            if (_medicoLocalStorage == null)
            {
                ToastService.ShowInfo("Falta informar o Médico!");
                await JSRuntime.ScrollToAsync();

                return;
            }

            await LocalStorage.CriaConsultaLocalStorageAsync(new ConsultaLocalStorage
            {
                Data          = _dataDaConsulta.Add(_horarioDaConsulta),
                Paciente      = _pacienteLocalStorage,
                Especialidade = _especialidadeLocalStorage,
                Medico        = _medicoLocalStorage,
            });

            NavigationManager.NavigateTo($"consultas/novo");
        }
        protected async override Task OnInitializedAsync()
        {
            var token = UserState.UserContext.AccessToken;

            HubConnection = new HubConnectionBuilder()
                            .WithUrl(NavigationManager.ToAbsoluteUri(Common.Global.Constants.Hubs.NotificationHub),
                                     options =>
            {
                options.AccessTokenProvider = () => Task.FromResult(token);
            })
                            .Build();

            HubConnection.On <NotificationModel>(Common.Global.Constants.Hubs.ReceiveMessage, (model) =>
            {
                ReceivedNotifications.Add(model);
                ToastService.ShowInfo(model.Message);
                StateHasChanged();
            });

            await HubConnection.StartAsync();
        }
        protected async Task UploadFile()
        {
            var data = await new EvalContext(JSRuntime).InvokeAsync <string>("MainInterop.getFileData()");

            try
            {
                Config = JsonSerializer.Deserialize <Models.OptimizerConfiguration>(data);

                StoreConfig(Config);

                Config.FitnessTypeName = Config.FitnessTypeName.Split('.').LastOrDefault();
            }
            catch (Exception)
            {
                ToastService.ShowError("The deserialization of config failed.");
                throw;
            }
            ToggleFitness();
            Json = data;
            ToastService.ShowInfo("Config was loaded");
            StateHasChanged();
        }
        private async Task BuscaPacienteAsync()
        {
            if (string.IsNullOrEmpty(_pacienteCodigoOuCPF) || _pacienteCodigoOuCPF.Length < 4)
            {
                ToastService.ShowInfo($"O código ou CPF {_pacienteCodigoOuCPF} do paciente está inválido!");
                return;
            }

            var paciente = await PacientesServico.GetPorCodigoOuCPFAsync(_pacienteCodigoOuCPF);

            if (paciente == null)
            {
                ToastService.ShowInfo("Nenhum paciente encontrado!");
                return;
            }

            _pacienteLocalStorage = new PacienteLocalStorage
            {
                Id   = paciente.Id,
                Nome = paciente.Nome
            };
        }
        public async Task HorariosDisponiveisAsync(DateTime dataDaConsulta)
        {
            if (!_agendarConsulta)
            {
                return;
            }

            if (_pacienteLocalStorage.Id == Guid.Empty)
            {
                ToastService.ShowInfo("Falta informar o Paciente!");
                await JSRuntime.ScrollToAsync();

                return;
            }

            if (_especialidadeLocalStorage == null)
            {
                ToastService.ShowInfo("Falta selecionar a Especialidade!");
                await JSRuntime.ScrollToAsync();

                return;
            }

            if (_medicoLocalStorage == null)
            {
                ToastService.ShowInfo("Falta selecionar a Médico!");
                await JSRuntime.ScrollToAsync();

                return;
            }

            _dataDaConsulta = dataDaConsulta.AddHours(-dataDaConsulta.Hour);

            _horariosDisponiveis = await EspecialidadesServico.GetHorariosDisponiveisAsync(_especialidadeLocalStorage.Id, _dataDaConsulta, _medicoLocalStorage?.Id);

            StateHasChanged();

            await JSRuntime.InvokeVoidAsync("calendarioDeConsultasJsInterop.showModalHorarioConsulta");
        }
예제 #17
0
        // string url = "https://lettings-manager.azurewebsites.net";
        protected override async Task OnInitializedAsync()
        {
            try
            {
                IsLoading = true;
                Houses    = await HouseSevices.GetHouses();

                //Houses = await http.GetFromJsonAsync<ReturnHousesDto[]>($"{url}/api/Houses/GetHouses");

                DataSource   = Houses;
                SearchSource = Houses;
                PageCount    = (int)Math.Ceiling((int)DataSource.Length / (decimal)ItemPerPage);
                Paginate(0);
                IsLoading = false;
                ToastService.ShowInfo("House Loaded", "Home list");
            }
            catch (Exception)
            {
                IsLoading = false;
                ToastService.ShowError("Error Loading List");
                throw;
            }
        }
예제 #18
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();
        }
        protected async Task OptimizeClick()
        {
            await Wait.Show();

            _stopWatch.Reset();
            _stopWatch.Start();

            IterationResult result = null;

            try
            {
                //Console.WriteLine(MinimizeFunctionCode.Code);

                OptimizerBase optimizer = null;
                if (MinimizeFunctionCode.Language == "javascript")
                {
                    optimizer = (JavascriptOptimizer)ServiceProvider.GetService(typeof(JavascriptOptimizer));
                }
                else if (MinimizeFunctionCode.Language == "csharp")
                {
                    optimizer = (CSharpThreadedOptimizer)ServiceProvider.GetService(typeof(CSharpThreadedOptimizer));
                }

                if (_config == null)
                {
                    ToastService.ShowError("No config was uploaded or created.");
                    await Wait.Hide();

                    return;
                }
                else
                {
                    var fitness = string.IsNullOrEmpty(_config.Fitness?.OptimizerTypeName) ? _config.FitnessTypeName : _config.Fitness.OptimizerTypeName;
                    ActivityLogger.ResetLog();
                    ActivityLogger.Add("Starting " + fitness);
                    optimizer.Initialize(MinimizeFunctionCode.Code, ActivityLogger);

                    TokenSource = new CancellationTokenSource();

                    var task = Task.Run(() => optimizer.Start(_config, TokenSource.Token), TokenSource.Token);

                    try
                    {
                        result = await task;
                    }
                    catch (TaskCanceledException)
                    {
                        CodeEditorBase.TokenSource = null;
                        await Wait.Hide();

                        ToastService.ShowInfo("Optimization was cancelled.");
                        TokenSource = null;
                        return;
                    }

                    TokenSource = null;

                    // Console.WriteLine(ActivityLogger.Log);

                    await JSRuntime.InvokeVoidAsync("ClientStorage.storeChartData", ActivityLogger.Log);

                    //todo: backticks
                    //dynamic context = new EvalContext(JSRuntime);
                    //(context as EvalContext).Expression = () => context.ClientStorage.storeChartData(ActivityLogger.Log);
                    //await (context as EvalContext).InvokeAsync<dynamic>();

                    ToastService.ShowSuccess("Chart data was saved.");
                }
            }
            catch (Exception ex)
            {
                await Wait.Hide();

                ToastService.ShowError(ex.Message);
                throw ex;
            }
            finally
            {
                await Wait.Hide();
            }

            _stopWatch.Stop();
            ToastService.ShowSuccess("Best Cost: " + result.Cost.ToString("N"));
            ToastService.ShowSuccess("Best Parameters: " + string.Join(",", result.ParameterSet.Select(s => s.ToString("N"))));
            ActivityLogger.Add("Best Cost: ", result.Cost);
            ActivityLogger.Add("Best Parameters: ", result.ParameterSet);
            ActivityLogger.Add("Total Time (s): ", _stopWatch.ElapsedMilliseconds / 1000);
        }
        protected async Task Salvar(EditContext editContext)
        {
            if (!editContext.Validate())
            {
                return;
            }

            var usuarioExiste = await UsuariosServico.GetPorEmailAsync(_usuarioViewModel.Email);

            if (_usuarioViewModel.Id == Guid.Empty && usuarioExiste != null)
            {
                ToastService.ShowInfo("Já existe um usuário cadastrado com este email!");
                return;
            }

            if (_senhaEdicao != _usuarioViewModel.Senha)
            {
                _usuarioViewModel.Senha = Encryption64.Encrypt(_usuarioViewModel.Senha);
            }

            switch (_usuarioViewModel.CargoId)
            {
            case CargosConst.Administrador:
                var administrador = Mapper.Map <AdministradorDTO>(_usuarioViewModel);
                await PostOrPutAsync(AdministradoresServico, administrador);

                break;

            case CargosConst.Recepcionista:
                var recepcionista = Mapper.Map <RecepcionistaDTO>(_usuarioViewModel);
                await PostOrPutAsync(RecepcionistasServico, recepcionista);

                break;

            case CargosConst.Laboratorio:
                var laboratorio = Mapper.Map <LaboratorioDTO>(_usuarioViewModel);
                await PostOrPutAsync(LaboratoriosServico, laboratorio);

                break;

            case CargosConst.Medico:
                var medicoExiste = await MedicosServico.GetPorCRMAsync(_usuarioViewModel.CRM);

                if (_usuarioViewModel.Id == Guid.Empty && medicoExiste != null)
                {
                    ToastService.ShowInfo($"O médico {medicoExiste.Nome} já está cadastrado com o CRM {_usuarioViewModel.CRM}!");
                    return;
                }

                if (!_usuarioViewModel.Especialidades.Any())
                {
                    ToastService.ShowInfo("Deve ser selecionado ao menos uma especialidade!");
                    return;
                }

                var horariosSelecionados = _usuarioViewModel.HorariosDeTrabalho.Where(_ => _.Selecionado);
                if (!horariosSelecionados.Any())
                {
                    ToastService.ShowInfo("Deve ser selecionado ao menos um horário de trabalho!");
                    return;
                }

                var medico = Mapper.Map <MedicoDTO>(_usuarioViewModel);
                await PostOrPutAsync(MedicosServico, medico);

                break;

            default:
                ToastService.ShowWarning("O cargo informado é inválido");
                break;
            }
        }