Exemplo n.º 1
0
        private void ChangeHouse(int?houseId)
        {
            FlatList.Clear();
            if (!houseId.HasValue)
            {
                return;
            }
            if (CanEdit)
            {
                AlertExists = _requestService.AlertCountByHouseId(houseId.Value) > 0;
            }
            foreach (var flat in _requestService.GetFlats(houseId.Value).OrderBy(s => s.TypeId).ThenBy(s => s.Flat?.PadLeft(6, '0')))
            {
                FlatList.Add(flat);
            }
            var serviceCompanyId = _requestService.GetServiceCompany(houseId.Value);

            _selectedServiceCompanyId = serviceCompanyId;

            foreach (var request in RequestList.Where(r => r.CanSave))
            {
                request.SelectedHouseId = houseId;
                if (serviceCompanyId != null)
                {
                    request.SelectedCompany = request.CompanyList.FirstOrDefault(c => c.Id == serviceCompanyId.Value);
                }
            }
            if (houseId.HasValue)
            {
                var house = _requestService.GetHouseById(houseId.Value);
                CommissioningDate = house.CommissioningDate;
                ElevatorCount     = house.ElevatorCount;
                ServiceCompany    = house.ServiceCompanyName;
            }
            else
            {
                CommissioningDate = null;
                ElevatorCount     = null;
            }

            OnPropertyChanged(nameof(FlatList));
        }