//GET
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var doctor = await _repository.GetById(id.Value);

            if (doctor == null)
            {
                return(NotFound());
            }

            var vm = _mapper.Map <DoctorViewModel>(doctor);

            var especilidadEntity = await _repositoryEspecialidad.GetAll();

            List <EspecialidadViewModel> listEspecialidadesVm = new List <EspecialidadViewModel>();

            especilidadEntity.ForEach(item =>
            {
                var vmEspecialidad = _mapper.Map <EspecialidadViewModel>(item);
                listEspecialidadesVm.Add(vmEspecialidad);
            });

            ViewBag.Especialidades = listEspecialidadesVm;

            var listEspecialidadIds = await _repositoryDoctorEspecialidad.GetDoctorEspecialidadIds(doctor.Id);

            vm.EspecialidadIds = listEspecialidadIds;


            return(View(vm));
        }
        public async Task <ActionResult> Put(int id, DoctorDtoUpdate dto)
        {
            var doctor = await _repository.GetById(id);

            if (doctor == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var response = await _repository.Update(id, dto);

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

            return(BadRequest());
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            var doctor = repo.GetById(id);

            if (doctor == null)
            {
                return(HttpNotFound());
            }
            return(View(doctor));
        }
Exemplo n.º 4
0
        // GET: Doctors/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Doctor doctor = doctorRepo.GetById(id.Value);

            if (doctor == null)
            {
                return(HttpNotFound());
            }
            return(View(doctor));
        }
Exemplo n.º 5
0
        public ActionResult Delete(int id)
        {
            var doc = doctorRepository.GetById(id);

            doctorRepository.Remove(doc);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public void GetByIdFalseInput()
        {
            EmptyLists();
            doctorRepository = new DoctorRepository(context);
            Exception ex = Assert.Throws <NullReferenceException>(() => doctorRepository.GetById(-1));

            Assert.Equal("Het dokterId is leeg.", ex.Message);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Detail page for doctor
        /// </summary>
        /// <param name="id">Id filter</param>
        /// <returns></returns>
        public IActionResult Details(long id)
        {
            // Check if id is set
            if (id < 1)
            {
                return(BadRequest("Id cannot be 0"));
            }

            // Retrieve doctor
            Doctor doctor = doctorRepository.GetById(id);

            if (doctor == null)
            {
                return(BadRequest("Department could not be found"));
            }

            // Convert to viewmodel and return in view
            DoctorDetailViewModel vm = converter.ModelToViewModel(doctor);

            return(View(vm));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Standard method
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            try
            {
                // Get user id
                var id = GetUserId();

                // Check if it exists
                if (id < 1)
                {
                    return(RedirectToAction("index", "home"));
                }

                UserViewModel viewModel = new UserViewModel();

                // Redirect user based on role
                if (HttpContext.User.IsInRole("patient"))
                {
                    Patient patient = patientRepository.GetById(id);
                    viewModel.Patient = patientConverter.ModelToViewModel(patient);
                }
                else if (HttpContext.User.IsInRole("doctor"))
                {
                    Doctor doctor = doctorRepository.GetById(id);
                    viewModel.Doctor = doctorConverter.ModelToViewModel(doctor);
                    //TODO : BY DOCTORID!!!!!!
                    viewModel.Doctor.TreatmentTypes = typeConverter.ModelsToViewModel(treatmentTypeRepository.GetAll());
                }

                return(View(viewModel));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 9
0
        public async Task <Doctor> GetById(Guid id)
        {
            var entity = await _repository.GetById(id);

            return(entity);
        }
Exemplo n.º 10
0
 public void GetById()
 {
     EmptyLists();
     doctorRepository = new DoctorRepository(context);
     Assert.Equal("SOOF", doctorRepository.GetById(12).UserName);
 }