コード例 #1
0
        public ActionResult Add()
        {
            var allRegions = _regionRepository.GetAll().Select(a => new SelectListItem
            {
                Text  = a.Name,
                Value = a.Id.ToString()
            }).ToList();

            var allWorkModes = _workModeRepository.GetAll().Select(a => new SelectListItem
            {
                Text  = a.Name,
                Value = a.Id.ToString()
            }).ToList();
            var allClinics = _clinicRepository.GetAll()
                             .Select(a => new SelectListItem
            {
                Text = a.Name, Value = a.Id.ToString()
            }
                                     ).ToList();
            var model = new AddViewModel {
                Clinics = allClinics, Regions = allRegions, WorkdModes = allWorkModes
            };

            if (User.IsInRole(Models.User.DOCTOR_ROLE))
            {
                var doctorId = User.FindFirstValue(ClaimTypes.NameIdentifier);

                var clinicId = _clinicRepository.GetDoctorsClinics(doctorId).FirstOrDefault().Id;

                model.ClinicId = clinicId;
            }
            return(View("Add", model));
        }
コード例 #2
0
        public IActionResult Index()
        {
            var allRegions = _regionRepository.GetAll().Select(a => new SelectListItem
            {
                Text  = a.Name,
                Value = a.Id.ToString()
            }).ToList();

            var allWorkModes = _workModeRepository.GetAll().Select(a => new SelectListItem
            {
                Text  = a.Name,
                Value = a.Id.ToString()
            }).ToList();

            var model = new HomeViewModel {
                Regions = allRegions, WorkdModes = allWorkModes
            };

            return(View(model));
        }