public ChangeHospitalRegistrationForSelectedSectionCommandAnswer ChangeHospitalRegistrationForSelectedSection(
            ChangeHospitalRegistrationForSelectedSectionCommand command)
        {
            var hospitalSectionProfilesName = _hospitalSectionProfileRepository.GetModels()
                .FirstOrDefault(model=>model.Id == command.HospitalProfileId).Name;

            var date = DateTime.ParseExact(command.Date.Split(' ').First(), "MM/dd/yyyy", CultureInfo.InvariantCulture);

            var emptyPlaceByTypeStatisticRepository = _emptyPlaceByTypeStatisticRepository.GetModels();

            var emptyPlaceId = _emptyPlaceStatisticRepository.GetModels()
                .Where(model => model.HospitalSectionProfileId == command.HospitalProfileId && model.Date == date).Select(m=>m.Id).ToList();

               var table = new List<HospitalRegistrationCountStatisticItem>();
            if (emptyPlaceId.Count > 1)
            {
                table = emptyPlaceId.Select(i => emptyPlaceByTypeStatisticRepository
                    .Where(model => model.EmptyPlaceStatistic.HospitalSectionProfileId == command.HospitalProfileId)
                    .Where(storageModel => storageModel.EmptyPlaceStatisticId.Equals(i))
                    .Select(model => new HospitalRegistrationCountStatisticItem
                    {
                        Sex = model.Sex,
                        OpenCount = model.Count,
                        Id = model.Id,
                        RegisteredCount = model.Reservations.Count(storageModel => storageModel.Status == ReservationStatus.Opened),
                        FreePlacesCount = model.Count - model.Reservations.Count(storageModel => storageModel.Status == ReservationStatus.Opened)
                    }).FirstOrDefault()).ToList();
            }
            else
            {
                table = emptyPlaceByTypeStatisticRepository
                    .Where(model => model.EmptyPlaceStatistic.HospitalSectionProfileId == command.HospitalProfileId)
                    .Where(storageModel => storageModel.EmptyPlaceStatisticId.Equals(emptyPlaceId.FirstOrDefault()))
                    .Select(model => new HospitalRegistrationCountStatisticItem
                    {
                        Sex = model.Sex,
                        OpenCount = model.Count,
                        Id = model.Id,
                        RegisteredCount = model.Reservations.Count(storageModel => storageModel.Status == ReservationStatus.Opened),
                        FreePlacesCount = model.Count - model.Reservations.Count(storageModel => storageModel.Status == ReservationStatus.Opened)
                    }).ToList();
            }

            table = FillRegistrationsForBothGenders(table);

            return new ChangeHospitalRegistrationForSelectedSectionCommandAnswer
            {
                Token = (Guid)command.Token,
                StatisticItems = table,
                Date = command.Date,
                SectionProfileName = hospitalSectionProfilesName,
                HospitalProfileId = command.HospitalProfileId
            };
        }
 public ActionResult ChangeHospitalRegistration(ChangeHospitalRegistrationForSelectedSectionCommand command)
 {
     var answer = _hospitalRegistrationsService.ChangeHospitalRegistrationForSelectedSection(command);
     return View(answer);
 }