예제 #1
0
        public ActionResult Edit(EditDoctorVM edit)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(edit));
            }

            UserService service = new UserService();
            User        user    = new User();

            user.Id        = edit.Id;
            user.Email     = edit.Email;
            user.Password  = edit.Password;
            user.Firstname = edit.Firstname;
            user.Lastname  = edit.Lastname;
            user.Phone     = edit.Phone;
            user.IsAdmin   = AuthenticationManager.LoggedUser.IsAdmin;

            service.Edit(user);

            if (edit.Specialization != null)
            {
                DoctorService serviceDoctor = new DoctorService();
                Doctor        doctor        = new Doctor();

                doctor.Specialization = edit.Specialization;
                doctor.Address        = edit.Address;
                doctor.UserId         = AuthenticationManager.LoggedUser.Id;

                serviceDoctor.Edit(doctor);
            }

            AuthenticationManager.Authenticate(AuthenticationManager.LoggedUser.Email, AuthenticationManager.LoggedUser.Password);
            return(RedirectToAction("Details", "Home"));
        }
        public async Task EditShouldReturnTrueAndProperCountOfDoctors()
        {
            var db                = Tests.GetDatabase();
            var doctorService     = new DoctorService(db, null);
            var departmentService = new DepartmentService(db);
            await departmentService.CreateAsync("Cardiology", "Gosho", "SomeURL");

            await db.SaveChangesAsync();

            await doctorService.CreateAsync(
                "Gosho", "*****@*****.**", "SomeURL", "Cardiologist", "Cardiology");

            await db.SaveChangesAsync();

            var id = await db.Doctors
                     .Where(d => d.Name == "Gosho")
                     .Select(d => d.Id)
                     .FirstOrDefaultAsync();

            var edited = await doctorService.Edit(
                id, "GoshoEdit", "*****@*****.**", "SomeEditURL", "CardiologistEdit", "Cardiology");

            await db.SaveChangesAsync();

            edited.Should()
            .BeTrue();

            db.Doctors.Should()
            .HaveCount(1);
        }
예제 #3
0
 public ActionResult Edit(int id, Doctor edited)
 {
     try
     {
         // TODO: Add update logic here
         Service.Edit(edited, id);
         return(RedirectToAction("Edit", "Doctor", new { Doctorid = id }));
     }
     catch
     {
         return(View());
     }
 }
        public void Edit()
        {
            //Arrange
            Mock <IDoctorRepository> mock = new Mock <IDoctorRepository>();
            int    id     = 0;
            Doctor doctor = new Doctor
            {
                Id               = 0,
                Deleted          = false,
                Expirience       = 10,
                HistoryIllnesses = null,
                Name             = "Petro",
                Surname          = "Petrov",
                Role             = EnumForMedicRole.Doctor,
                Specialty        = ClassificationOfDoctors.Гинеколог,
                User             = null,
                UserId           = Guid.NewGuid().ToString()
            };
            List <Doctor> doctors = new List <Doctor>()
            {
                doctor
            };

            mock.Setup(x => x.GetById(id)).Returns(doctors.Where(d => d.Id == id).FirstOrDefault());
            DoctorViewModel doctorViewModel = new DoctorViewModel
            {
                Id   = id,
                Name = "Vasya"
            };
            Mock <IUnitOfWork> mock2 = new Mock <IUnitOfWork>();

            mock2.Setup(x => x.Doctors).Returns(mock.Object);
            mock2.Setup(x => x.Save());

            var service = new DoctorService(mock2.Object, null, null);

            //Act
            service.Edit(doctorViewModel);

            //Assert
            if (string.IsNullOrEmpty(doctorViewModel.Name))
            {
                Assert.AreEqual(doctorViewModel.Name, doctorViewModel.Name);
            }
        }
 public Doctor Edit(Doctor obj)
 {
     return(_service.Edit(obj));
 }