コード例 #1
0
        public void AddDoctor_ValidatesRequest()
        {
            //arrange
            var request = _fixture.Create <AddDoctorRequest>();

            //act
            _doctorService.AddDoctor(request);

            //assert
            _validator.Verify(x => x.ValidateRequest(request), Times.Once);
        }
コード例 #2
0
        private void confirmBtn_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" ||
                textBox5.Text == "" || comboBox1.Text == "" || textBox8.Text == "" || textBox7.Text == "")
            {
                MessageBox.Show("Provide all information...");
            }
            else
            {
                Doctor edoctor = new Doctor();
                edoctor.Name = textBox2.Text;

                edoctor.Gender            = comboBox1.Text;
                edoctor.Phone             = textBox4.Text;
                edoctor.Address           = textBox3.Text;
                edoctor.Dob               = textBox8.Text;
                edoctor.Salary            = Convert.ToDouble(textBox7.Text);
                edoctor.Password          = textBox1.Text;
                edoctor.WId               = Convert.ToInt32(textBox5.Text);
                edoctor.NotificationCount = 0;
                edoctor.Notfication       = null;

                DoctorService doctorServices = new DoctorService();
                bool          check          = doctorServices.AddDoctor(edoctor);
                if (check)
                {
                    MessageBox.Show("Doctor Added");
                }
                else
                {
                    MessageBox.Show("Error Occured !");
                }
            }
        }
コード例 #3
0
        public void SVDebePoderGuadarUnDoctor()
        {
            var data = new List <Doctor>
            {
            }.AsQueryable();

            var dbset = new Mock <DbSet <Doctor> >();

            dbset.As <IQueryable <Doctor> >().Setup(m => m.Provider).Returns(data.Provider);
            dbset.As <IQueryable <Doctor> >().Setup(m => m.Expression).Returns(data.Expression);
            dbset.As <IQueryable <Doctor> >().Setup(m => m.ElementType).Returns(data.ElementType);
            dbset.As <IQueryable <Doctor> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var context = new Mock <OpticaContext>();

            context.Setup(a => a.Doctores).Returns(dbset.Object);

            var service = new DoctorService(context.Object);

            var doctor = new Doctor
            {
                Apellidos       = "Coral",
                Celular         = "11111",
                Nombres         = "Anderson",
                NumeroDocumento = "4783434",
                TipoDocumento   = TipoDocumento.DNI,
            };

            var guardar = service.AddDoctor(doctor);

            Assert.AreEqual(true, guardar);
            Assert.IsTrue(guardar);
        }
コード例 #4
0
 public ActionResult <IEnumerable <Doctor> > CreateNew([FromBody] Doctor doctor)
 {
     if (doctor is null)
     {
         return(NotFound());
     }
     if (doctor.Id != 0)
     {
         return(BadRequest());
     }
     return(Ok(doctorService.AddDoctor(doctor)));
 }
コード例 #5
0
        public ResponseResult <Cookie> Reg([FromBody] Doctor doctor)
        {
            ResponseResult <Cookie> result = new ResponseResult <Cookie>();

            try
            {
                DoctorService doctorService = new DoctorService();
                result.Result = doctorService.AddDoctor(doctor);
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message   = e.Message;
            }
            return(result);
        }
コード例 #6
0
        private void btnAddDoctor_Click(object sender, EventArgs e)
        {
            lbError.Text = "";
            DoctorService service = new DoctorService();

            if (!string.IsNullOrEmpty(txtDoctorFirstName.Text) &&
                !string.IsNullOrEmpty(txtDoctorLastName.Text) &&
                !string.IsNullOrEmpty(txtDoctorPatronimic.Text) &&
                !string.IsNullOrEmpty(txtDoctorPosition.Text) &&
                !string.IsNullOrEmpty(txtSpec.Text))
            {
                Doctor doctor = new Doctor()
                {
                    FirstName      = txtDoctorFirstName.Text,
                    LastName       = txtDoctorLastName.Text,
                    Patronimic     = txtDoctorPatronimic.Text,
                    Position       = txtDoctorPosition.Text,
                    Specialization = txtSpec.Text,
                    Id             = Guid.NewGuid().ToString()
                };
                service.AddDoctor(doctor);


                var doctors = service.GetAll();
                dgDoctor.Rows.Clear();
                if (doctors != null)
                {
                    foreach (var p in doctors)
                    {
                        dgDoctor.Rows.Add(p.Position, p.FirstName, p.LastName, p.Patronimic, p.Specialization, p.Id);
                    }
                }
            }
            else
            {
                lbError.Text = "Filed can't be empty";
            }
        }
コード例 #7
0
 public void AddDoctor(Doctor doctor)
 {
     doctorService.AddDoctor(doctor);
 }
 public void AddDoctor(Doctor newDoctor)
 {
     doctorService.AddDoctor(newDoctor);
 }
コード例 #9
0
        public async Task <IHttpActionResult> AddDoctor([FromBody] DoctorRegistrationDTO doctorInfo)
        {
            UserModel userModel = new UserModel()
            {
                Username = doctorInfo.DoctorNIN,
                Password = doctorInfo.Password
            };

            IdentityResult result = await authRepository.RegisterUser(userModel);

            IHttpActionResult errorResult = GetErrorResult(result, ErrorCode.AccountAlreadyExistsWithThisNIN);

            if (errorResult != null)
            {
                return(errorResult);
            }

            var user = await authRepository.UserManager.FindByNameAsync(userModel.Username);

            if (user == null)
            {
                return(InternalServerError());
            }

            IdentityResult addRoleResult = await authRepository.UserManager.AddToRoleAsync(user.Id, "Doctor");

            errorResult = GetErrorResult(addRoleResult, ErrorCode.DoctorCouldNotBeAddedToRole);

            if (errorResult != null)
            {
                return(errorResult);
            }

            HealthCareFacilitiesService facilityService = new HealthCareFacilitiesService();
            var facility = facilityService.GetFacilityByName(doctorInfo.HealthcareFacilityName);

            if (facility == null)
            {
                facilityService.AddHealthcareFacilite(doctorInfo.HealthcareFacilityName);
            }

            facility = facilityService.GetFacilityByName(doctorInfo.HealthcareFacilityName);

            if (facility == null)
            {
                return(InternalServerError());
            }

            var doctor = new DoctorDTO()
            {
                DoctorNIN            = doctorInfo.DoctorNIN,
                DoctorName           = doctorInfo.DoctorName,
                DoctorEmail          = doctorInfo.DoctorEmail,
                DoctorPhoneNumber    = doctorInfo.DoctorPhoneNumber,
                DoctorPosition       = doctorInfo.DoctorPosition,
                DoctorUIN            = doctorInfo.DoctorUIN,
                HealthcareFacilityId = facility.Id
            };

            var doctorService = new DoctorService();

            doctorsService.AddDoctor(doctor);

            return(Ok());
        }