Exemplo n.º 1
0
        public void GetByDepartmentFalseInput()
        {
            EmptyLists();
            doctorRepository = new DoctorRepository(context);
            Exception ex = Assert.Throws <NullReferenceException>(() => doctorRepository.GetByDoctorWithDepartment(-1));

            Assert.Equal("Het afdelingId is leeg.", ex.Message);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Page list of doctors
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            DoctorViewModel vm      = new DoctorViewModel();
            List <Doctor>   doctors = new List <Doctor>();

            if (User.IsInRole("admin"))
            {
                // Retrieve doctors
                doctors = doctorRepository.GetAll();
                if (doctors.Count < 1)
                {
                    return(View());
                }
            }
            else if (User.IsInRole("doctor"))
            {
                long userId = GetUserId();
                doctors = doctorRepository.GetByDoctorWithDepartment(userId);
                if (doctors.Count < 1)
                {
                    return(View());
                }
            }

            // Convert to viewmodels
            vm.Doctors = converter.ModelsToViewModel(doctors);
            //foreach(Doctor doctor in doctors)
            //{
            //    UserAccount account = accounts.FirstOrDefault(a => a.DoctorId == doctor.Id);
            //    if (account == null)
            //    {
            //        continue;
            //    }

            //    doctor.Name = account.Name;
            //    vm.Doctors.Add(converter.ModelToViewModel(doctor));
            //}

            return(View(vm));
        }
Exemplo n.º 3
0
 public void GetByDepartment()
 {
     EmptyLists();
     doctorRepository = new DoctorRepository(context);
     Assert.Equal(2, doctorRepository.GetByDoctorWithDepartment(1).Count);
 }