/// <summary>
 /// Создание нового объекта BuildingMonthVariables.
 /// </summary>
 /// <param name="id">Исходное значение свойства Id.</param>
 /// <param name="calculationArea">Исходное значение свойства CalculationArea.</param>
 /// <param name="countOfPeople">Исходное значение свойства CountOfPeople.</param>
 public static BuildingMonthVariables CreateBuildingMonthVariables(global::System.Int32 id, global::System.Double calculationArea, global::System.Int32 countOfPeople)
 {
     BuildingMonthVariables buildingMonthVariables = new BuildingMonthVariables();
     buildingMonthVariables.Id = id;
     buildingMonthVariables.CalculationArea = calculationArea;
     buildingMonthVariables.CountOfPeople = countOfPeople;
     return buildingMonthVariables;
 }
        public void CreateNormativeAndProjectCalculation()
        {
            if (SelectedBuilding == null)
                return;

            if (SelectedInterval == null)
                return;

            var totalArea = Buildings.Single(building => building.Id == SelectedBuilding.Id).TotalArea;
            var calculationArea = Double.Parse(CalculationArea);
            var standartHeat = Double.Parse(Standart);
            var consumptionByTotalArea = _standartCalculator.CalculateConsumptionByArea(totalArea, standartHeat);
            var consumptionByCalculationArea = _standartCalculator.CalculateConsumptionByArea(calculationArea, standartHeat);

            var month = SelectedThermometerReading.Month;
            var year = SelectedThermometerReading.Year;
            var countOfPeople = int.Parse(PeopleCount);
            var consumptionByLoad = _projectCalculator.ConsumptionByLoad(SelectedBuilding.StandartOfHeat, DateTime.DaysInMonth(year, month), SelectedThermometerReading.AirTemperature);
            var hotWaterByNorm = _projectCalculator.HotWaterByNorm(countOfPeople);
            var totalHeatConsumption = _projectCalculator.TotalHeatConsumption(consumptionByLoad, hotWaterByNorm);

            var normativeCalculation = new NormativeCalculation
                                           {
                                               EstimateConsumptionHeat = standartHeat,
                                               ConsumptionHeatByTotalArea = consumptionByTotalArea,
                                               ConsumptionHeatByCalculationArea = consumptionByCalculationArea,
                                               TotalHeatConsumption = totalHeatConsumption,
                                               Building = SelectedBuilding,
                                               DateTimeInterval = SelectedInterval
                                           };

            _normativeRepository.InsertNormativeCalculations(normativeCalculation);
            _normativeRepository.Save();

            var projectCalculation = new ContractConsumptionHeat
                                          {
                                              HeatByLoading = consumptionByLoad,
                                              HotWaterByNorm = hotWaterByNorm,
                                              TotalHeatConsumption = totalHeatConsumption,
                                              Building = SelectedBuilding,
                                              DateTimeInterval = SelectedInterval,
                                              ThermometerReading = SelectedThermometerReading
                                          };

            _projectRepository.InsertConstractConsumption(projectCalculation);
            _projectRepository.Save();
            //Consumptions.Add(contractConsumption);

            var variables = new BuildingMonthVariables
                                {
                                    CalculationArea = calculationArea,
                                    CountOfPeople = countOfPeople,
                                    Building = SelectedBuilding,
                                    DateTimeInterval = SelectedInterval
                                };
            _variablesRepository.InsertBuildingMonthVariables(variables);
            _variablesRepository.Save();
        }
 /// <summary>
 /// Устаревший метод для добавления новых объектов в набор EntitySet BuildingMonthVariablesTable. Взамен можно использовать метод .Add связанного свойства ObjectSet&lt;T&gt;.
 /// </summary>
 public void AddToBuildingMonthVariablesTable(BuildingMonthVariables buildingMonthVariables)
 {
     base.AddObject("BuildingMonthVariablesTable", buildingMonthVariables);
 }