示例#1
0
        public ActionResult Details(int id)
        {
            var service = new ClinicService();
            var model   = service.GetClinicById(id);

            return(View(model));
        }
示例#2
0
        public async Task GetClinicById_WithInvalidId_ShouldReturnException()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);
            var clinic    = new Clinic
            {
                Id   = 20,
                Name = "Clinic 20"
            };
            var clinic2 = new Clinic
            {
                Id   = 21,
                Name = "Clinic 21"
            };

            dbContext.Clinics.Add(clinic);
            dbContext.Clinics.Add(clinic2);
            await dbContext.SaveChangesAsync();

            var repository = new DbRepository <Clinic>(dbContext);
            var service    = new ClinicService(repository);

            Assert.Throws <ArgumentException>(() => service.GetClinicById(22));
        }
示例#3
0
        public void GetClinicById_WithValidId_ShouldReturnClinic()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);
            var clinic    = new Clinic
            {
                Id   = 10,
                Name = "Clinic 10"
            };
            var clinic2 = new Clinic
            {
                Id   = 11,
                Name = "clinic 11"
            };

            dbContext.Clinics.Add(clinic);
            dbContext.Clinics.Add(clinic2);
            dbContext.SaveChanges();

            var repository = new DbRepository <Clinic>(dbContext);
            var service    = new ClinicService(repository);
            var result     = service.GetClinicById(11);

            Assert.Same(clinic2, result);
        }
示例#4
0
        public void GetClinicById_WithEmptyClinicSet_ShouldReturnException()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);

            var repository = new DbRepository <Clinic>(dbContext);
            var service    = new ClinicService(repository);

            Assert.Throws <ArgumentException>(() => service.GetClinicById(7));
        }
示例#5
0
        //GET: Edit
        public ActionResult Edit(int id)
        {
            var service = new ClinicService();
            var detail  = service.GetClinicById(id);
            var model   = new ClinicEdit
            {
                ClinicId = detail.ClinicId,
                Name     = detail.Name,
                Address  = detail.Address,
                City     = detail.City,
                State    = detail.State,
                Zip      = detail.Zip,
                Phone    = detail.Phone
            };

            return(View(model));
        }