public IActionResult Index(HeatCostViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var cost        = HeatCalculatorService.CalculateCost(model.SizeInSquareFeet, ClimateZone.FromValue(model.ClimateZoneId).Code);
            var resultModel = new HeatCostResultViewModel()
            {
                ClimateZone      = ClimateZone.FromValue(model.ClimateZoneId).Name,
                SizeInSquareFeet = model.SizeInSquareFeet,
                Cost             = cost
            };

            return(View("Result", resultModel));
        }
Exemplo n.º 2
0
        public static List <ClimateZone> SelectInfoByZoneId(int zoneId)
        {
            List <ClimateZone> list = new List <ClimateZone>();

            DataProvider.ExecuteCmd(GetConnection, "dbo.ClimateZones_SelectByZoneId"
                                    , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Id", zoneId);
            }, map : delegate(IDataReader reader, short set)
            {
                ClimateZone z     = new ClimateZone();
                int startingIndex = 0;
                z.Id          = reader.GetSafeInt32(startingIndex++);
                z.Name        = reader.GetSafeString(startingIndex++);
                z.Description = reader.GetSafeString(startingIndex++);
                z.ImageUrl    = reader.GetSafeString(startingIndex++);
                z.Color       = reader.GetSafeString(startingIndex++);
                list.Add(z);
            });
            return(list);
        }