Exemple #1
0
        public void Get_All_Tariffs()
        {
            var tariffs    = new AvailableTariff();
            var allTariffs = tariffs.GetAllTariffs();

            Assert.Equal(2, allTariffs.Count);
            Assert.NotEmpty(allTariffs);
        }
Exemple #2
0
        public IActionResult Get([FromQuery(Name = "consumption")] double consumption)
        {
            try
            {
                var availableTariffs = new AvailableTariff();
                var result           = availableTariffs.GetAllTariffs()
                                       .Select(i => new { i.Name, AnnualCost = i.CostCalulation(consumption) })
                                       .Distinct()
                                       .OrderBy(i => i.AnnualCost)
                                       .ToList();

                return(Ok(result));
            }
            catch (Exception e)
            {
                return(BadRequest($"Can't get the tariff {e.Message}"));
            }
        }