예제 #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));
        }
예제 #2
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));
            }
        }