Ejemplo n.º 1
0
        public void AddTest()
        {
            repository.Add(doctor);

            bool result = dbContext.SaveChanges() > 0;

            Assert.IsTrue(result);
        }
        /// <summary>
        /// 同步医护人员(新增或修改)
        /// </summary>
        /// <param name="sync"></param>
        /// <returns>是否保存成功</returns>
        public async Task <OutputBase> AddOrUpdate(AddDoctorSync sync)
        {
            var doctor = await _repository.Get(sync.DialysisDoctorId, sync.HospitalId);

            if (doctor == null)
            {
                _repository.Add(Mapper.Map <AddDoctorSync, Doctor>(sync));
            }
            else
            {
                Mapper.Map <AddDoctorSync, Doctor>(sync, doctor);
                doctor.UpdateTime = DateTime.Now;
            }

            return(_unitWork.Commit() ? OutputBase.Success("保存成功") : OutputBase.Fail("保存失败"));
        }
        public async Task <IActionResult> Create(DoctorViewModel vm, IFormFile Photo)
        {
            if (ModelState.IsValid)
            {
                string uniqueName = null;

                if (Photo != null)
                {
                    var folderPath = Path.Combine(_hostingEnvironment.WebRootPath, "images/Doctor");

                    uniqueName = Guid.NewGuid().ToString() + "_" + Photo.FileName;

                    var filePath = Path.Combine(folderPath, uniqueName);

                    if (filePath != null)
                    {
                        var stream = new FileStream(filePath, mode: FileMode.Create);
                        Photo.CopyTo(stream);
                        stream.Flush();
                        stream.Close();
                    }
                }

                var doctorEntity = _mapper.Map <Doctor>(vm);
                doctorEntity.ProfilePhoto = uniqueName;

                await _repository.Add(doctorEntity);

                await _repositoryDoctorEspecialidad.AddDoctorEspecialidades(vm.EspecialidadIds, doctorEntity.Id);

                return(RedirectToAction("Index"));
            }

            return(View(vm));
        }
Ejemplo n.º 4
0
        public async void AddDoctor_Successful_Test()
        {
            var doctor = new Doctor {
                IsLock = false, Firstname = "Иван", Lastname = "Иванов", Middlename = "Иванович"
            };

            _doctorRepository.Add(doctor);
            await _doctorRepository.SaveAllAsync();

            var doctors = await _doctorRepository.GetDoctorsRepositoryAsync(DoctorsType.AllDoctors);

            Assert.Single(doctors);
            Assert.Equal(1, doctors.FirstOrDefault().Id);
            Assert.Equal("Иван", doctors.FirstOrDefault().Firstname);
            Assert.False(doctors.FirstOrDefault().IsLock);
        }
Ejemplo n.º 5
0
        public void AddTest()
        {
            doctorRepository.Add(doctor);
            patientRepository.Add(patient);
            sessionrepository.Add(session);
            bool result = dbContext.SaveChanges() > 2;

            Assert.IsTrue(result);
            Transaction.Current.Rollback();
        }
Ejemplo n.º 6
0
        public ActionResult New(DoctorViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var doctor = Mapper.Map <Doctor>(viewModel);
                doctorRepository.Add(doctor);

                return(RedirectToAction("Index"));
            }

            return(View(viewModel));
        }
Ejemplo n.º 7
0
        public IActionResult Create([Bind("Crm,Uf,Phone,Specialty,Id,Name,Email,Password")] DoctorViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var doctor = Mapper.Map <Doctor>(viewModel);
                doctorRepository.Add(doctor);

                return(RedirectToAction("Index"));
            }

            return(View(viewModel));
        }
 public IActionResult AddDoctor([FromBody] Doctor doctor, string adminName)
 {
     if (loggedInAdmins.checkIfLoggedIn(adminName))
     {
         var addedDoctor = doctorRepository.Add(doctor);
         return(Ok(addedDoctor));
     }
     else
     {
         return(Ok());
     }
 }
Ejemplo n.º 9
0
        public IActionResult Post([FromBody] Doctor doctor)
        {
            if (doctor == null)
            {
                return(BadRequest("doctor is null."));
            }

            _doctorRepository.Add(doctor);
            return(CreatedAtRoute(
                       "Get",
                       new { TypeName = doctor.TypeName },
                       doctor));
        }
Ejemplo n.º 10
0
        public void CountTest()
        {
            int count;

            using (var context = new DataContext())
            {
                BaseRepository <Doctor> doctors = new DoctorRepository(context);
                var doc = new Doctor("Ivan", "Ivanov", "Surgeon");
                doctors.Add(doc);
                doctors.Save();

                count = doctors.Count(d => d.Name == "Ivan");
            }

            Assert.AreEqual(1, count);
        }
        public async Task <ActionResult> Post(DoctorDtoUpdate dto)
        {
            if (ModelState.IsValid)
            {
                var response = await _repository.Add(dto);

                if (response)
                {
                    return(NoContent());
                }
                else
                {
                    return(StatusCode(500));
                }
            }

            return(BadRequest());
        }
Ejemplo n.º 12
0
        public IActionResult Create(DoctorCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = ProcessUploadedFile(model);
                Doctor newDoctor      = new Doctor
                {
                    FirstName   = model.FirstName,
                    LastName    = model.LastName,
                    Specialty   = model.Specialty,
                    Email       = model.Email,
                    Description = model.Description,
                    PhotoPath   = uniqueFileName
                };

                _doctorRepository.Add(newDoctor);

                return(RedirectToAction("details", new { id = newDoctor.DoctorID }));
            }
            return(View());
        }
Ejemplo n.º 13
0
        public async Task <ActionResult> RegisterDoctor(LoginRegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName  = model.RegisterViewModel.Email,
                    Email     = model.RegisterViewModel.Email,
                    FirstName = model.RegisterViewModel.FirstName,
                    LastName  = model.RegisterViewModel.LastName,
                };

                // Add the Address properties:



                var result = await UserManager.CreateAsync(user, model.RegisterViewModel.Password);

                dynamic addedResult;
                if (result.Succeeded)
                {
                    SessionHandler.UserName = model.RegisterViewModel.Email;
                    SessionHandler.Password = model.RegisterViewModel.Password;
                    SessionHandler.UserId   = user.Id;


                    DoctorRepository objRepo = new DoctorRepository();
                    Doctor           obj     = new Doctor
                    {
                        userId    = user.Id,
                        lastName  = user.LastName,
                        firstName = user.FirstName,
                        email     = user.Email,
                        status    = false
                    };
                    addedResult = objRepo.Add(obj);

                    if (addedResult != null)
                    {
                        ViewBag.success = "Your Account has been created, You can login after approval of your account.";
                        //Send Simple Email

                        var sampleEmailBody = @"
                        <h3>Mail From SwiftKare</h3>
                        <p>Your account has been created with SwiftKare successfully.</p>
                        <p>You can login after approval of your account.</p>
                        <p>&nbsp;</p>
                        <p><strong>-Best Regards,<br/>SwiftKare</strong></p>
                        ";

                        var oSimpleEmail = new EmailHelper(obj.email, "SwiftKare Membership", sampleEmailBody);
                        oSimpleEmail.SendMessage();
                        return(View("DoctorLogin", model));
                    }
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form

            //return View("Login", model);
            return(View("DoctorLogin", model));
        }
Ejemplo n.º 14
0
        public async Task <ActionResult> Register(LoginRegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName  = model.RegisterViewModel.Email,
                    Email     = model.RegisterViewModel.Email,
                    FirstName = model.RegisterViewModel.FirstName,
                    LastName  = model.RegisterViewModel.LastName,
                };

                // Add the Address properties:



                var result = await UserManager.CreateAsync(user, model.RegisterViewModel.Password);

                dynamic addedResult;
                if (result.Succeeded)
                {
                    SessionHandler.UserName = model.RegisterViewModel.Email;
                    SessionHandler.Password = model.RegisterViewModel.Password;
                    SessionHandler.UserId   = user.Id;

                    if (model.IsPatient)
                    {
                        PatientRepository objRepo = new PatientRepository();
                        Patient           obj     = new Patient
                        {
                            userId    = user.Id,
                            lastName  = user.LastName,
                            firstName = user.FirstName,
                            email     = user.Email
                        };
                        addedResult = objRepo.Add(obj);
                    }
                    else
                    {
                        DoctorRepository objRepo = new DoctorRepository();
                        Doctor           obj     = new Doctor
                        {
                            userId    = user.Id,
                            lastName  = user.LastName,
                            firstName = user.FirstName,
                            email     = user.Email
                        };
                        addedResult = objRepo.Add(obj);
                    }
                    if (addedResult != null)
                    {
                        ViewBag.SuccessMessage = "Your Account has been created, please login";
                        return(View("Login"));
                    }
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form

            //return View("Login", model);
            return(View("Login", model));
        }
 public void Post([FromBody] Doctor p)
 {
     _repository.Add(p);
 }
Ejemplo n.º 16
0
        public async Task <Doctor> Add(Doctor entity)
        {
            await _repository.Add(entity);

            return(entity);
        }
Ejemplo n.º 17
0
 public Doctor Add(Doctor doctor)
 {
     return(_doctorRepository.Add(doctor));
 }