コード例 #1
0
 public ActionResult Step2(GetHospitalRegistrationUserFormCommand command)
 {
     var answer = _clinicRegistrationsService.GetHospitalRegistrationUserForm(command);
     return View(answer);
 }
コード例 #2
0
        public GetHospitalRegistrationUserFormCommandAnswer GetHospitalRegistrationUserForm(
            GetHospitalRegistrationUserFormCommand command)
        {
            var clinics = this._clinicRepository.GetModels().ToList();
            if (command.ClinicId == null)
            {
                command.ClinicId = clinics.FirstOrDefault().Id;
            }
            var clinicResults = clinics.Select(model => new KeyValuePair<int, string>(model.Id, model.Name)).ToList();

            var users = this._userRepository.GetModels().Where(model => model.ClinicUser != null && model.ClinicUser.ClinicId == command.ClinicId.Value).ToList();
            if (command.UserId == null || users.Select(model => model.Id).All(i => command.UserId.Value != i))
            {
                command.UserId = users.FirstOrDefault().Id;
            }
            var userResults = users.Select(model => new KeyValuePair<int, string>(model.Id, model.Name)).ToList();

            var hospitalSectionProfile =
                this._hospitalSectionProfileRepository.GetModels()
                    .FirstOrDefault(model => model.Id == command.HospitalSectionProfileId)
                    .Name;

            if (command.Code == null)
            {
                command.Code = Guid.NewGuid().ToString();
            }

            return new GetHospitalRegistrationUserFormCommandAnswer
            {
                Token = command.Token.Value,
                SexId = command.SexId,
                HospitalSectionProfileId = command.HospitalSectionProfileId,
                Sex = ((Sex)command.SexId).ToCorrectString(),
                ClinicId = command.ClinicId.Value,
                LastName = command.LastName,
                FirstName = command.FirstName,
                Date = command.Date,////DateTime.Parse(command.Date).ToCorrectDateString(),
                PhoneNumber = command.PhoneNumber,
                Years = command.Years ?? 0,
                Months = command.Months ?? 0,
                Weeks = command.Weeks ?? 0,
                Code = command.Code,
                Diagnosis = command.Diagnosis,
                MedicalExaminationResult = command.MedicalExaminationResult,
                MedicalConsultion = command.MedicalConsultion,
                ReservationPurpose = command.ReservationPurpose,
                OtherInformation = command.OtherInformation,
                DoesAgree = command.DoesAgree ?? true,
                UserId = command.UserId.Value,
                Clinics = clinicResults,
                Users = userResults,
                HospitalSectionProfile = hospitalSectionProfile,
                AgeCategoryId = command.AgeCategoryId
            };
        }