Beispiel #1
0
        public ActionResult <Doctor> Get(int id)
        {
            Doctor result = doctorService.FindDoctor(id);

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
Beispiel #2
0
        public void simpleFindersShouldWork()
        {
            // Arrange
            ApplicationDbContext dbContext     = Shared.GetDatabaseContext();
            DoctorService        doctorService = new DoctorService(dbContext);
            var doctors = new[]
            {
                new Doctor {
                    Id = 1, Specialization = "a"
                },
                new Doctor {
                    Id = 2, Specialization = "b"
                },
                new Doctor {
                    Id = 3, Specialization = "c"
                },
            };

            dbContext.Doctors.AddRange(doctors);
            dbContext.SaveChanges();

            // Act
            Doctor foundDoctor = doctorService.FindDoctor(2);

            Doctor[] foundDoctors = doctorService.FindAllDoctors();

            // Assert
            Assert.Equal(2, foundDoctor.Id);
            Assert.Equal("b", foundDoctor.Specialization);
            Assert.Collection(foundDoctors,
                              doc => Assert.Equal(1, doc.Id),
                              doc => Assert.Equal(2, doc.Id),
                              doc => Assert.Equal(3, doc.Id)
                              );
        }
        public IActionResult View(int id,
                                  [FromQuery(Name = "date")] DateTime date,
                                  [FromQuery(Name = "patient")] int?patientId
                                  )
        {
            Doctor doctor = doctorService.FindDoctor(id);

            if (doctor == null)
            {
                logger.LogError("There was en error while trying to find doctor");
                Response.StatusCode = 404;
                return(View("NotFound"));
            }

            DoctorViewModel viewModel = new DoctorViewModel(doctor, doctorService);

            ViewBag.doctorView = viewModel;
            ViewBag.freeHours  = doctorService.ComputeFreeSlots(doctor, date);
            ViewBag.date       = date;
            ViewBag.patientId  = patientId;
            return(View());
        }