public ActionResult Index(GetMakeClinicRegistrationsPageInformationCommand command) { var answer = _clinicRegistrationsService.GetMakeClinicRegistrationsPageInformation(command); return View(answer); }
public GetMakeClinicRegistrationsPageInformationCommandAnswer GetMakeClinicRegistrationsPageInformation( GetMakeClinicRegistrationsPageInformationCommand command) { var user = this._tokenManager.GetUserByToken(command.Token); var clinic = this._clinicManager.GetClinicByUser(user); var hasGenderFactor = !clinic.IsForChildren; var sexes = Enum.GetValues(typeof (Sex)) .Cast<Sex>() .Select(sex => new KeyValuePair<int, string>((int) sex, sex.ToCorrectString())) .ToList(); var hospitalSectionProfileIds = _clinicUserHospitalSectionProfileAccessRepository .GetModels() .Where(model => !model.IsBlocked && model.ClinicUserId == user.Id) .Select(model => model.HospitalSectionProfileId) .Distinct() .ToList(); var sectionProfiles = _hospitalSectionProfileRepository.GetModels() .Where(model => hospitalSectionProfileIds.Any(id => id == model.Id)) .Select(model => new { Id = model.SectionProfileId, Name = model.SectionProfile.Name }) .ToList() .Select(profile => new KeyValuePair<int, string>(profile.Id, profile.Name)) .Distinct() .ToList(); return new GetMakeClinicRegistrationsPageInformationCommandAnswer { Token = command.Token.Value, SectionProfiles = sectionProfiles, SectionProfile = sectionProfiles.FirstOrDefault().Value, Sexes = sexes, Sex = sexes.FirstOrDefault().Value, HasGenderFactor = hasGenderFactor }; }