protected override async Task OnInitializedAsync()
        {
            var auth      = await AuthenticationStateTask;
            var stockUser = UserRepository.GetByEmail(auth.User.Identity.Name);

            if (stockUser == null || stockUser.StockRole != StockRole.ADMIN)
            {
                Telemetry.TrackEvent("AccessDenied");
                NavigationManager.NavigateTo("/accessdenied");
                return;
            }

            try
            {
                _categories = await Repository.GetAllAsync <Category>();

                _sortedCategories = new List <Category>(_categories);
                _suppliers        = await Repository.GetAllAsync <Supplier>();

                _sortedSuppliers = new List <Supplier>(_suppliers);
            } catch (Exception e)
            {
                Telemetry.TrackException(e);
                ToastService.ShowWarning("Probleem bij het inladen van data, herlaad de pagina.");
            }
        }
        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();
        }
        private async Task Deploy()
        {
            //deploy contract
            TonContractDeployResult deploy = await TonClient.Contracts.Deploy(new TonContractDeployParams
            {
                Package = ContractPackage,
                KeyPair = KeyPair
            }).CatchJsExceptionAsync(ex => ToastService.ShowError(ex.Message));

            if (deploy.AlreadyDeployed)
            {
                ToastService.ShowWarning("Contract already deployed");
                ProgressCurrentStep++;
                DeployContractResult = true;
                return;
            }

            if (deploy.Transaction?.Compute?.Success ?? false)
            {
                ToastService.ShowSuccess($"GasFees:{deploy.Transaction.Compute.GasFees}", "Contract has been deployed");
                ProgressCurrentStep++;
                DeployContractResult = true;
                return;
            }

            ToastService.ShowError(JsonSerializer.Serialize(deploy), "Something went wrong");
        }
        protected override async Task OnInitializedAsync()
        {
            var auth      = await AuthenticationStateTask;
            var stockUser = UserRepository.GetByEmail(auth.User.Identity.Name);

            if (stockUser == null || stockUser.StockRole != StockRole.ADMIN)
            {
                Telemetry.TrackEvent("AccessDenied");
                NavigationManager.NavigateTo("/accessdenied");
                return;
            }

            try
            {
                if (Id != null)
                {
                    _category = (Category)await Repository.GetByIdAsync(typeof(Category), Id);
                }
                _editContext = new EditContext(_category);
            } catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowWarning("Fout bij het inladen van de data, herlaad de pagina.");
            }
        }
Example #5
0
        protected override async Task OnInitializedAsync()
        {
            var auth      = await AuthenticationStateTask;
            var stockUser = UserRepository.GetByEmail(auth.User.Identity.Name);

            if (stockUser == null || stockUser.StockRole != StockRole.ADMIN)
            {
                Telemetry.TrackEvent("AccessDenied");
                NavigationManager.NavigateTo("/accessdenied");
                return;
            }

            try
            {
                _category = (Category)await Repository.GetByIdAsync(typeof(Category), Id);

                _products = await Repository.GetByCategoryAsync(Id);

                _filteredProducts = new List <Product>(_products);
                if (_products != null)
                {
                    foreach (Product prod in _products)
                    {
                        prod.AmountInStock = await Repository.GetAmountInStockValueAsync(prod.Id);
                    }
                }
            } catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowWarning("Probleem bij het inladen van de data, herlaad de pagina.");
            }
        }
 protected override async Task OnInitializedAsync()
 {
     try
     {
         //_categories = (await Repository.GetAllAsync<Category>())?.Where(c => c.IsVisible).OrderBy(c => c.CategoryName);
     } catch (Exception ex)
     {
         Telemetry.TrackException(ex);
         ToastService.ShowWarning("Fout bij het inladen van de data, herlaad de pagina.");
     }
 }
        protected override async Task OnInitializedAsync()
        {
            try
            {
                _item = await Repository.GetItemDetails(Id);

                _itemusers = (await Repository.GetItemUsersByItem(Id))?.OrderByDescending(i => i.FromDate).ToList();
            } catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowWarning("Fout bij het inladen van de data, herlaad de pagina.");
            }
        }
Example #8
0
 protected void Submit()
 {
     if (_item != null)
     {
         ParentItem.AddItem(_item);
         Repository.Save(ParentItem);
         BlazoredModal.Close(ModalResult.Ok <Item>(_item));
         ToastService.ShowSuccess("Item inbegrepen");
     }
     else
     {
         ToastService.ShowWarning("Selecteer een item.");
     }
 }
        protected async Task Submit()
        {
            if (string.IsNullOrWhiteSpace(_productNumber))
            {
                ToastService.ShowWarning("Selecteer of scan een product.");
                return;
            }
            var auth      = await AuthenticationStateTask;
            var stockUser = UserRepository.GetByEmail(auth.User.Identity.Name);

            if (_item == null)
            {
                if (string.IsNullOrWhiteSpace(_serialNumber))
                {
                    ToastService.ShowWarning("Selecteer of scan een serienummer.");
                    return;
                }


                _item = await Repository.GetItemByProductAndSerialNumberAsync(_productNumber, _serialNumber);

                if (_item == null)
                {
                    ToastService.ShowWarning("Item bestaat niet.");
                    return;
                }
            }

            if (Method == "out")
            {
                var res = HandleOut(stockUser);
                if (!res)
                {
                    return;
                }
            }
            else
            {
                var res = await HandleReturn(stockUser);

                if (!res)
                {
                    return;
                }
            }

            _item         = null;
            _serialNumber = null;
        }
Example #10
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                var auth = await AuthenticationStateTask;
                _loggedInUser = UserRepository.GetByEmail(auth.User.Identity.Name);
                _itemusers    = (await Repository.GetItemUsersByUser(Id)).Where(i => i.ToDate != null).ToList();
                _user         = await UserRepository.GetUserDetailsAsync(Id);

                _items = await Repository.GetItemsByUserAsync(Id);
            }
            catch (Exception ex) {
                Telemetry.TrackException(ex);
                ToastService.ShowWarning("Fout bij het inladen van de data, herlaad de pagina.");
            }
        }
Example #11
0
        public async Task FetchProducts()
        {
            try
            {
                if (_selectedCategory != null)
                {
                    _products = await Repository.GetByCategoryAsync((int)_selectedCategory);

                    _selectedProduct = _item.Product?.Id;
                }
            } catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowWarning("Fout bij het inladen van de producten, herlaad de pagina.");
            }
        }
Example #12
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                //_category = ((Category)await Repository.GetByIdAsync(typeof(Category), Id))?.CategoryName;
                _products = await Repository.GetByCategoryAsync(Id);

                //foreach (Product prod in _products)
                //{
                //    prod.AmountInStock = await Repository.GetAmountInStockValueAsync(prod.Id);
                //}
                _filteredProducts = new List <Product>(_products);
                toRenderList      = _filteredProducts.GetRange(0, 50);
            } catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowWarning("Fout bij het inladen van de data, herlaad de pagina.");
            }
        }
Example #13
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                _categories = await Repository.GetAllAsync <Category>();

                _suppliers = await Repository.GetAllAsync <Supplier>();

                _item = (Item)await Repository.GetByIdAsync(typeof(Item), Id);

                _users = await Repository.GetAllAsync <ADUser>();

                if (_item == null)
                {
                    NavigationManager.NavigateTo("error");
                }
                else
                {
                    _initialUser      = _item.ADUser;
                    _initialStatus    = _item.ItemStatus;
                    _selectedCategory = _item.Product.Category.Id;
                    _serialNumber     = _item.SerialNumber;
                    await FetchProducts();

                    _selectedSupplier = _item.Supplier?.Id;
                    _comment          = _item.Comment;
                    _deliveryDate     = _item.DeliveryDate;
                    _invoiceDate      = _item.InvoiceDate;
                    _selectedStatus   = _item.ItemStatus;
                    _imei             = _item.Imei;
                    _vgdnumber        = _item.Imei;
                    _license          = _item.License;
                    _hostname         = _item.Hostname;
                    _carepack         = _item.Carepack;
                    _initialUser      = _item.ADUser;
                }
            } catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowWarning("Fout bij het inladen van de data, herlaad de pagina.");
            }
        }
        private bool HandleOut(ADUser stockUser)
        {
            if (_item.ItemStatus != ItemStatus.INSTOCK)
            {
                ToastService.ShowWarning("Item kan niet uit stock gehaald worden met status: " + _item.ItemStatus.ToString());
                return(false);
            }
            GraphUser graphUser = userSearch.GetSelectedUser();

            if (graphUser == null)
            {
                ToastService.ShowWarning("Selecteer een gebruiker.");
                return(false);
            }
            ADUser aduser = UserRepository.GetByEmail(graphUser.Mail);

            if (aduser == null)
            {
                aduser = new ADUser(graphUser);
                try
                {
                    Repository.Save(aduser);
                } catch (Exception ex)
                {
                    Telemetry.TrackException(ex);
                    return(false);
                }
            }
            _item.RemoveFromStock(aduser, stockUser);
            try
            {
                Repository.Save(_item);
                Telemetry.TrackEvent("ItemOut");
                ToastService.ShowSuccess("Item uit stock gehaald, er zijn nog " + _item.Product.Items.Where(i => i.ItemStatus == ItemStatus.INSTOCK).Count() + " items van dit product.");
            } catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowError("Kon item niet uit stock halen.");
                return(false);
            }
            return(true);
        }
        private async Task <bool> HandleReturn(ADUser stockUser)
        {
            if (_item.ItemStatus != ItemStatus.OUTSTOCK)
            {
                Telemetry.TrackEvent("InvalidIn");
                ToastService.ShowWarning("Item kan niet geretourneerd worden met status: " + _item.ItemStatus.ToString());
                return(false);
            }

            _item.ReturnToStock(stockUser);
            if (_isDefective)
            {
                _item.ItemStatus = ItemStatus.DEFECTIVE;
            }
            _item.Comment = _comment;
            try
            {
                Repository.Save(_item);
                _comment = null;
                ToastService.ShowSuccess("Item in stock geplaatst, er zijn " + _item.Product.Items.Where(i => i.ItemStatus == ItemStatus.INSTOCK).Count() + " items van dit product.");
                if (!await _fileUpload.IsEmpty())
                {
                    try
                    {
                        await _fileUpload.Upload("item" + _item?.Id, "item" + _item.Id + DateTime.Now.ToString("ddMMyyyyHHmmss"));
                    }
                    catch (Exception ex)
                    {
                        Telemetry.TrackException(ex);
                        ToastService.ShowWarning("Kon bestand niet uploaden.");
                        return(false);
                    }
                }
            } catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowError("Kon item niet in stock plaatsen.");
                return(false);
            }
            return(true);
        }
Example #16
0
        protected async override Task <bool> Salvar(EditContext editContext)
        {
            _carregando = true;
            StateHasChanged();

            if (string.IsNullOrEmpty(_dto.LinkResultadoExame) && _dto.StatusExame.Id == StatusExameConst.EmAnaliseLaboratorial)
            {
                ToastService.ShowWarning("Não foi realizado o envio do resultados!");
                _carregando = false;
                StateHasChanged();
                return(false);
            }

            _dto.LaboratorioRealizouExameId = ApplicationState.UsuarioLogado.Id;
            _dto.StatusExame.Id             = _dto.StatusExame.Id == StatusExameConst.Pendente ? StatusExameConst.EmAnaliseLaboratorial : StatusExameConst.Concluido;

            await HttpServico.PutAsync(_dto.Id, _dto);

            await JSRuntime.ForceReloadAsync();

            return(true);
        }
Example #17
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                if (Id != null)
                {
                    _product = (Product)await Repository.GetByIdAsync(typeof(Product), Id);

                    _items = await Repository.GetByProductAsync(_product.Id);
                }
                if (SupplierId != null)
                {
                    _supplier = (Supplier)await Repository.GetByIdAsync(typeof(Supplier), SupplierId);

                    _items = await Repository.GetBySupplierAsync(_supplier.Id);
                }
                _filteredItems = new List <Item>(_items).OrderBy(i => i.SerialNumber);
            }
            catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowWarning("Fout bij het inladen van de data, herlaad de pagina.");
            }
        }
Example #18
0
 private void DeleteProduct(Product product)
 {
     if (product.Items.Count == 0)
     {
         try
         {
             Repository.Delete(product);
             _products.Remove(product);
             _filteredProducts.Remove(product);
             _category.Products.Remove(product);
             Telemetry.TrackEvent("ProductDelete");
         }
         catch (Exception ex)
         {
             Telemetry.TrackException(ex);
             ToastService.ShowError("Kon product niet verwijderen.");
         }
     }
     else
     {
         Telemetry.TrackEvent("ProductDeleteFail");
         ToastService.ShowWarning("Product heeft nog items.");
     }
 }
        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;
            }
        }
Example #20
0
        protected async Task Submit()
        {
            var auth      = AuthenticationStateTask.Result;
            var stockuser = UserRepository.GetByEmail(auth.User.Identity.Name);

            if (string.IsNullOrWhiteSpace(_serialNumber))
            {
                ToastService.ShowWarning("Serienummer mag niet leeg zijn.");
                return;
            }
            _item.SerialNumber = Regex.Replace(_serialNumber, @"\s+", "");

            if (_selectedProduct == null)
            {
                ToastService.ShowWarning("Selecteer een product.");
                return;
            }
            _item.Product = _products.First(i => _selectedProduct == i.Id);
            if (_selectedSupplier == null)
            {
                ToastService.ShowWarning("Selecteer een leverancier.");
                return;
            }

            if (_initialStatus != _selectedStatus)
            {
                _item.ChangeStatus(_selectedStatus, stockuser);
            }

            if (_item.ItemStatus == ItemStatus.OUTSTOCK)
            {
                var selectedUser = userSearch.GetSelectedUser();
                if (selectedUser != null)
                {
                    if (_initialUser?.Id != selectedUser?.Id)
                    {
                        _item.ReturnToStock(stockuser);
                        ADUser newUser = null;

                        if (!UserRepository.ADUserExists(selectedUser.Id))
                        {
                            newUser = new ADUser(selectedUser);
                            Repository.Save(newUser);
                        }
                        else
                        {
                            newUser = (ADUser)UserRepository.GetById(typeof(ADUser), selectedUser.Id);
                        }

                        _item.RemoveFromStock(newUser, stockuser);
                    }
                }
            }

            _item.Supplier     = _suppliers.First(i => _selectedSupplier == i.Id);
            _item.Comment      = _comment;
            _item.DeliveryDate = _deliveryDate;
            _item.InvoiceDate  = _invoiceDate;

            _item.Carepack  = string.IsNullOrWhiteSpace(_carepack) ? null : _carepack;
            _item.Hostname  = string.IsNullOrWhiteSpace(_hostname) ? null : _hostname;
            _item.Imei      = string.IsNullOrWhiteSpace(_imei) ? null : _imei;
            _item.License   = string.IsNullOrWhiteSpace(_license) ? null : _license;
            _item.VGDNumber = string.IsNullOrWhiteSpace(_vgdnumber) ? null : _vgdnumber;
            try
            {
                Repository.Save(_item);
            } catch (Exception ex)
            {
                Telemetry.TrackException(ex);
                ToastService.ShowError("Kon item niet opslaan.");
            }

            if (!await _fileUpload.IsEmpty())
            {
                try
                {
                    await Upload(_item);
                }
                catch (Exception ex)
                {
                    Telemetry.TrackException(ex);
                    ToastService.ShowError("Kon foto niet opslaan.");
                }
            }
            Telemetry.TrackEvent("ItemUpdate");
            ToastService.ShowSuccess("Item succesvol geëditeerd.");
            NavigationManager.NavigateTo("itemhistoriek/" + _item.Id);
        }