public IActionResult Index(int?doctorId)
        {
            var result = new ClientListViewModel();

            result.ClientVMList = new List <ClientViewModel>();

            List <Client> cltList;

            //----Determine list of Clients ---------------------------------------

            if (!doctorId.HasValue) // Admin vraagt lijst op van alle clienten
            {
                cltList = _clientManager.SelectAllClientsAdmin(out int nrOfClients);
            }
            else  // Doctor vraagt lijst op van zijn eigen clienten
            {
                result.DoctorId       = doctorId.Value;
                result.DoctorFullName = _clientManager.DoctorFullName(doctorId.Value);
                cltList = _clientManager.SelectAllClientsPerDoctor((int)doctorId, out int nrOfClients);
            }

            // Copy clientList to clientListViewModel.
            for (int i = 0; i < cltList.Count; i++)
            {
                // Map Client naar ClientVM via extension method:
                var c1 = cltList[i];
                var c2 = cltList[i].ToClientVM(); // Vul de basisvelden van c2

                // Voeg afgeleide velden toe aan c2
                c2.AgeInDays      = (int)(DateTime.Today.Subtract(c1.BirthDate)).TotalDays;
                c2.ClientFullName = c1.FirstName + "  " + c1.LastName;

                c2.NrofPrescriptions = _clientManager.GetNrOfPrescrPerClient(c1.Id);
                c2.DoctorFullName    = _clientManager.DoctorFullName(c1.DoctorId);

                result.ClientVMList.Add(c2);
            }
            ;

            // sorteer result.ClientVMList op ClientFullName

            result.ClientVMList = result
                                  .ClientVMList
                                  .OrderBy(c => c.ClientFullName)
                                  .ToList();

            return(View(result));
        }
Esempio n. 2
0
        public IActionResult Index(int?doctorId, string prefixString,
                                   string subString, bool sortOnClientNumber, bool sortOnFirstName)
        {
            /* Prefix:  (sortOnClientNumber != null XOR sortOnFirstName != null)
             *                  XOR
             *          (prefixString != null XOR subString != null)
             */

            var result = new ClientListViewModel
            {
                ClientVMList = new List <ClientViewModel>()
            };

            List <Client> cltList;

            //----Determine list of Clients ---------------------------------------


            if (!doctorId.HasValue) // Admin vraagt lijst op van alle clienten
            {
                cltList = _clientManager.SelectAllClientsAdmin(out int nrOfClients);
            }
            else  // Doctor vraagt lijst op van zijn eigen clienten
            {
                result.DoctorId       = doctorId.Value;
                result.DoctorFullName = _clientManager.DoctorFullName(doctorId.Value);
                cltList = _clientManager.SelectAllClientsPerDoctor((int)doctorId, out int nrOfClients);
            }

            var countryList = _countryManager.GetAllCountries();

            // Copy clientList to clientListViewModel.
            for (int i = 0; i < cltList.Count; i++)
            {
                // Map Client naar ClientVM via extension method:
                var c1 = cltList[i];
                var c2 = cltList[i].ToClientVM(); // Vul de basisvelden van c2

                // Voeg afgeleide velden toe aan c2
                c2.AgeInDays      = (int)(DateTime.Today.Subtract(c1.BirthDate)).TotalDays;
                c2.ClientFullName = c1.FirstName + "  " + c1.LastName;

                c2.NrofPrescriptions = _clientManager.GetNrOfPrescrPerClient(c1.Id);
                c2.DoctorFullName    = _clientManager.DoctorFullName(c1.DoctorId);
                // Voeg alle landen toe aan de individuele client
                c2.Countries = countryList;

                result.ClientVMList.Add(c2);
            }
            ;

            // Als de buttons sortOnClientNumber of sortOnFirstName zijn geklikt, hebben deze voorrang
            // Negeer de teksten in prefixString en subString
            if (sortOnClientNumber || sortOnFirstName)
            {
                prefixString = null;
                subString    = null;
            }

            // Als prefixString is ingevuld: Toon dan alle clienten wiens voornaam begint met deze prefix
            // Als subString is ingevuld: Toon dan alle clienten met deze substring ergens in voor-achternaam, of zelfs
            // de substring in de concat voornaam-achternaam

            // sorteer result.ClientVMList op ClientFullName

            if (prefixString == null && subString == null)
            {
                if (sortOnFirstName)
                {
                    result.ClientVMList = result
                                          .ClientVMList
                                          .OrderBy(c => c.ClientFullName)
                                          .ToList();
                }
                if (sortOnClientNumber)
                {
                    result.ClientVMList = result
                                          .ClientVMList
                                          .OrderBy(c => c.Client.ClientNumber)
                                          .ToList();
                }
            }
            else if (subString != null)
            {
                result.ClientVMList = result
                                      .ClientVMList.
                                      Where(c => c.Client.FirstName.ToLower()
                                            .Contains(subString.ToLower())
                                            ||
                                            c.Client.LastName.ToLower()
                                            .Contains(subString.ToLower())
                                            )
                                      .OrderBy(c => c.ClientFullName)
                                      .ToList();
            }
            else if (prefixString != null)
            {
                result.ClientVMList = result
                                      .ClientVMList.
                                      Where(c => c.Client.FirstName.ToLower()
                                            .StartsWith(prefixString.ToLower())
                                            ||
                                            c.Client.LastName.ToLower()
                                            .StartsWith(prefixString.ToLower())
                                            )
                                      .OrderBy(c => c.ClientFullName)
                                      .ToList();
            }

            if (subString != null)
            {
                _logger.LogDebug($"DEBUG INFO VAN JPVA - De lijst van clienten is opgevraagd " +
                                 $"met substring \"{subString}\" ");
                _logger.LogDebug($"DEBUG INFO VAN JPVA - Er werden {result.ClientVMList.Count} cliënten getoond");


                _logger.LogInformation($"INFORMATION INFO VAN JPVA - De lijst van clienten is opgevraagd " +
                                       $"met substring \"{subString}\" ");
                _logger.LogInformation($"INFORMATION INFO VAN JPVA - Er werden {result.ClientVMList.Count} cliënten getoond");

                //------------------------------------------

                _logger.LogWarning($"WARNING INFO VAN JPVA - De lijst van clienten is opgevraagd " +
                                   $"met substring \"{subString}\" ");
                _logger.LogWarning($"WARNING INFO VAN JPVA - Er werden {result.ClientVMList.Count} cliënten getoond");


                _logger.LogError($"ERROR INFO VAN JPVA - De lijst van clienten is opgevraagd " +
                                 $"met substring \"{subString}\" ");
                _logger.LogError($"ERROR INFO VAN JPVA - Er werden {result.ClientVMList.Count} cliënten getoond");
            }


            result.PrefixString = null;
            result.SubString    = null;

            // ModelState.Clear:
            // Anders worden de input teksten (prefix en substring) niet geschoond
            // Bij redisplay

            ModelState.Clear();
            return(View(result));
        }
Esempio n. 3
0
        // -----------------------------------------------------------------------------------------------------------------


        public IActionResult Index(int?doctorId, int?clientId)
        {
            List <Consult> listCons;
            var            consListVM = new ConsultListViewModel(); // Deze gaat de index view in

            consListVM.ConsultList = new List <ConsultViewModel>();

            // - 1. Determine full names of client and doctor on top of the view:
            if (clientId.HasValue)
            {
                consListVM.ClientId       = clientId;
                consListVM.ClientFullName = _clientManager.ClientFullName(clientId.Value);
            }

            if (doctorId.HasValue)
            {
                consListVM.DoctorId       = doctorId;
                consListVM.DoctorFullName = _clientManager.DoctorFullName(doctorId.Value);
            }

            //----2. Determine list of Consults ---------------------------------------

            if (!doctorId.HasValue && !clientId.HasValue)
            // Admin wil lijst van alle consulten zien
            {
                listCons = _consultManager.GetAll();
            }

            else if (!doctorId.HasValue && clientId.HasValue)
            // Een client logt in, ziet alle consulten van al zijn artsen
            {
                var clt = _clientManager.GetClient(clientId.Value);
                consListVM.ClientId = clt.Id;

                listCons = _consultManager.GetAllPerClient(clientId.Value);
            }

            else if (doctorId.HasValue && !clientId.HasValue)
            // Een doctor vraagt alle recepten op van al zijn clienten
            {
                listCons            = _consultManager.GetAllPerDoctor(doctorId.Value);
                consListVM.DoctorId = doctorId;
            }

            else // beiden ongelijk null
            // Als vanuit de clienten-lijst een lijst van recepten wordt opgehaald
            {
                listCons            = _consultManager.GetAllPerDoctorPerClient((int)doctorId, (int)clientId);
                consListVM.ClientId = clientId;
                consListVM.DoctorId = doctorId;
            }

            for (int i = 0; i < listCons.Count; i++)
            {
                consListVM.ConsultList.Add
                (
                    new ConsultViewModel
                {
                    Consult        = listCons[i],
                    ClientFullName = _clientManager.ClientFullName(listCons[i].ClientId),
                    DoctorFullName = _clientManager.DoctorFullName(listCons[i].DoctorId)
                }
                );
            }

            return(View(consListVM));
        }
        public IActionResult Index(int?doctorId, int?clientId)
        // In de index tabel staan geen Prescription Lines
        {
            List <Prescription> listPrescr;
            var prescrListVM = new PrescrListViewModel();

            // In de index tabel staan geen Prescription Lines,
            // Wel bevat iedere Prescripton de volledige cient en dokter naam
            prescrListVM.PrescrList = new List <PrescrWithNames>();

            // - Determine full names of client and doctor on top of the view:
            if (clientId.HasValue)
            {
                gClientId                   = clientId;
                prescrListVM.ClientId       = clientId;
                prescrListVM.ClientFullName = _clientManager.ClientFullName(clientId.Value);
            }

            if (doctorId.HasValue)
            {
                gDoctorId                   = doctorId;
                prescrListVM.DoctorId       = doctorId;
                prescrListVM.DoctorFullName = _clientManager.DoctorFullName(doctorId.Value);
            }

            //----Determine list of Prescriptions ---------------------------------------

            if (!doctorId.HasValue && !clientId.HasValue)
            // Admin wil lijst van alle recepten zien
            {
                listPrescr = _prescrManager.GetAll();
            }

            else if (!doctorId.HasValue && clientId.HasValue)
            // Een client logt in
            {
                var clt = _clientManager.GetClient(clientId.Value);
                prescrListVM.ClientId = clt.Id;

                listPrescr = _prescrManager.GetAllPerClient(clientId.Value);
            }

            else if (doctorId.HasValue && !clientId.HasValue)
            // Een doctor vraagt alle recepten op van al zijn clienten
            {
                listPrescr            = _prescrManager.GetAllPerDoctor(doctorId.Value);
                prescrListVM.DoctorId = doctorId;
            }

            else // beiden ongelijk null
            // Als vanuit de clienten-lijst een lijst van recepten wordt opgehaald
            {
                listPrescr            = _prescrManager.GetAllPerDoctorPerClient((int)doctorId, (int)clientId);
                prescrListVM.ClientId = clientId;
                prescrListVM.DoctorId = doctorId;
            }

            for (int i = 0; i < listPrescr.Count; i++)
            {
                prescrListVM.PrescrList.Add
                (
                    new PrescrWithNames
                {
                    Prescripton    = listPrescr[i],
                    ClientFullName = _clientManager.ClientFullName(listPrescr[i].ClientId),
                    DoctorFullName = _clientManager.DoctorFullName(listPrescr[i].DoctorId)
                }
                );
            }

            return(View(prescrListVM));
        }
Esempio n. 5
0
        public IActionResult Index(int?doctorId, int?clientId)
        // In de index tabel staan geen Prescription Lines
        {
            List <Invoice> listInvoiceDb;
            var            invoiceListVM = new InvoiceListViewModel
            {
                // In de index tabel staan geen Invoice Lines, maar ze worden wel
                // meegegeven in deze ViewModel.
                InvoiceList = new List <InvoiceViewModel>()
            }; // Deze gaat de index view in

            // - Determine full names of client and doctor on top of the view:
            if (clientId.HasValue)
            {
                invoiceListVM.ClientId       = clientId;
                invoiceListVM.ClientFullName = _clientManager.ClientFullName(clientId.Value);
                var clt = _clientManager.GetClient(clientId.Value);
                invoiceListVM.ClientNumber     = clt.ClientNumber;
                invoiceListVM.NumberOfInvoices = _invoiceManager.NumberOfInvoicesPerClient(clientId.Value);
            }

            if (doctorId.HasValue)
            {
                invoiceListVM.DoctorId       = doctorId;
                invoiceListVM.DoctorFullName = _clientManager.DoctorFullName(doctorId.Value);
            }

            //----Determine list of invoices ---------------------------------------

            if (!doctorId.HasValue && !clientId.HasValue)
            // Admin wil lijst van alle recepten zien
            {
                listInvoiceDb = _invoiceManager.GetAll();
            }

            else if (!doctorId.HasValue && clientId.HasValue)
            // Een client logt in
            {
                var clt = _clientManager.GetClient(clientId.Value);
                invoiceListVM.ClientId = clt.Id;

                listInvoiceDb = _invoiceManager.GetAllPerClient(clientId.Value);
            }

            else if (doctorId.HasValue && !clientId.HasValue)
            // Een doctor vraagt alle recepten op van al zijn clienten
            {
                listInvoiceDb          = _invoiceManager.GetAllPerDoctor(doctorId.Value);
                invoiceListVM.DoctorId = doctorId;
            }

            else // beiden ongelijk null
            // Als vanuit de clienten-lijst een lijst van recepten wordt opgehaald
            {
                listInvoiceDb          = _invoiceManager.GetAllPerDoctorPerClient((int)doctorId, (int)clientId);
                invoiceListVM.ClientId = clientId;
                invoiceListVM.DoctorId = doctorId;
            }

            for (int i = 0; i < listInvoiceDb.Count; i++)
            {
                invoiceListVM.InvoiceList.Add
                (
                    new InvoiceViewModel
                {
                    Invoice        = listInvoiceDb[i],
                    ClientFullName = _clientManager.ClientFullName(listInvoiceDb[i].ClientId),
                    DoctorFullName = _clientManager.DoctorFullName(listInvoiceDb[i].DoctorId),
                    // We tonen geen factuur-lijnen in het index-lijst-scherm
                    // Onderstaande regels kan je ook weglaten
                    Line1 = null,
                    Line2 = null,
                    Line3 = null
                }
                );;
            }

            return(View(invoiceListVM));
        }