public ShowAutocompletePageCommandAnswer ShowAutocompletePage(ShowAutocompletePageCommand command)
        {
            var user = this._tokenManager.GetUserByToken(command.Token.Value);
            var hospital = this._hospitalManager.GetHospitalByUser(user);

            var sectionsAccessIds = _hospitalUserSectionAccessRepository.GetModels().Where(model => !model.IsBlocked).Where(model => model.HospitalUserId == user.Id)
                .Select(model => model.HospitalSectionProfileId).ToList();

            var hospitalSectionProfiles =
                this._hospitalSectionProfileRepository.GetModels().Where(model => model.HospitalId == hospital.Id).Where(model => sectionsAccessIds.Contains(model.Id))
                .ToList();

            if (command.HospitalSectionProfileId == null || command.HospitalSectionProfileId == 0)
            {
                command.HospitalSectionProfileId = hospitalSectionProfiles.FirstOrDefault().Id;
            }

            var hasGenderFactor = hospitalSectionProfiles.FirstOrDefault().HasGenderFactor;

            if ((command.SexId == null || command.SexId == 0) && hasGenderFactor)
            {
                command.SexId = (int)Sex.Male;
            }

            var sexes = Enum.GetValues(typeof(Sex))
                .Cast<Sex>()
                .Select(sex => new KeyValuePair<int, string>((int)sex, sex.ToCorrectString()))
                .ToList();

            var hospitalSectionProfilePairs =
                hospitalSectionProfiles.Select(model => new KeyValuePair<int, string>(model.Id, model.Name)).ToList();

            var daysOfWeek = command.DaysOfWeek;
            if (daysOfWeek == null || !daysOfWeek.Any())
            {
                daysOfWeek = @Enum.GetValues(typeof (DayOfWeek)).Cast<DayOfWeek>().Select(week => true).ToList();
            }

            return new ShowAutocompletePageCommandAnswer
            {
                Token = command.Token.Value,
                SexId = command.SexId,
                HospitalSectionProfileId = command.HospitalSectionProfileId.Value,
                Sexes = sexes,
                HospitalSectionProfiles = hospitalSectionProfilePairs,
                HasGenderFactor = hasGenderFactor,
                DaysOfWeek = daysOfWeek,
                HasDialogMessage = command.HasDialogMessage != null && command.HasDialogMessage.Value,
                DialogMessage = command.DialogMessage
            };
        }
        public ActionResult ShowAutocompletePage(ShowAutocompletePageCommand command)
        {
            var answer = _hospitalRegistrationsService.ShowAutocompletePage(command);

            return View(answer);
        }