Esempio n. 1
0
        public IActionResult Create(long id = 0)
        {
            // Get and convert treatment
            TreatmentDetailViewModel vm = new TreatmentDetailViewModel
            {
                Patients       = PatientConverter.PatientlistToViewModel(patientRepository.GetAll()),
                TreatmentTypes = TypeConverter.ModelsToViewModel(treatmentTypeRepository.GetAll()),
                PatientId      = id
            };

            return(View(vm));
        }
        /// <summary>
        /// The home screen of treatmenttypes that gets all treatmenttypes and converts them to a list of viewmodels.
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            TreatmentTypeViewModel vm = new TreatmentTypeViewModel()
            {
                TreatmentTypes = new List <TreatmentTypeDetailViewModel>()
            };

            // Retrieve all treatmenttypes
            List <TreatmentType> treatmentTypes = repository.GetAll();

            if (treatmentTypes.Count < 1)
            {
                return(View(vm));
            }

            vm.TreatmentTypes = converter.ModelsToViewModel(treatmentTypes);
            return(View(vm));
        }
Esempio n. 3
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));
            }
        }
 public void GetAll()
 {
     EmptyLists();
     treatmentTypeRepository = new TreatmentTypeRepository(context);
     Assert.Equal(2, treatmentTypeRepository.GetAll().Count);
 }