Ejemplo n.º 1
0
        public EditLegacyBuildingWizard(Building SelectedBuilding = null)
        {
            InitializeComponent();
            DataContext = this;

            MetersCollection = new ObservableCollection <MeterType>();
            InitializeCategoriesList();
            InitializeUnitsList();
            InitializeCostCollection();
            CostBeggining = DateTime.Today;
            if (SelectedBuilding != null)
            {
                _buildingLocalCopy = new Building(SelectedBuilding);

                BuildingName       = SelectedBuilding.Name;
                BuildingCity       = SelectedBuilding.City;
                BuildingZipCode    = SelectedBuilding.ZipCode;
                BuildingRoadName   = SelectedBuilding.RoadName;
                BuildingRoadNumber = SelectedBuilding.BuildingNumber;

                foreach (var c in SelectedBuilding.CostCollection)
                {
                    var clv = new Helpers.CostListView {
                        BegginingDate = c.BegginingDate.Date, EndingDate = c.EndingDate.Date, Cost = c.CostPerUnit, CostUnit = UnitsNames.Where(x => x.EnumValue == c.BuildingChargeBasisDistribution).FirstOrDefault(), CategoryName = CategoriesNames.Where(x => x.BuildingChargeBasisCategoryId.Equals(c.BuildingChargeBasisCategoryId)).FirstOrDefault().CategoryName, CostGroup = GroupNames.Where(x => x.BuildingChargeGroupNameId == c.BuildingChargeGroupNameId).FirstOrDefault()
                    };
                    CostCollection.Add(clv);
                }
                MetersCollection = new ObservableCollection <MeterType>(SelectedBuilding.MeterCollection);
            }
            if (_buildingLocalCopy != null)
            {
                GroupBankAccounts = new ObservableCollection <BuildingChargeGroupBankAccount>(GroupBankAccountsTotal.Where(x => !x.IsDeleted && x.Building.BuildingId == _buildingLocalCopy.BuildingId).ToList());
            }
            else
            {
                GroupBankAccounts = new ObservableCollection <BuildingChargeGroupBankAccount>();
            }
        }