Beispiel #1
0
        static void Main(string[] args)
        {
            Volume volume = new Volume()
            {
                HouseId   = 0,
                ServiceId = 0,
                Month     = new DateTime(2021, 5, 10),
                Value     = 10
            };
            Tariff tariff = new Tariff()
            {
                ServiceId   = 0,
                HouseId     = 0,
                PeriodBegin = new DateTime(2021, 1, 1),
                PeriodEnd   = new DateTime(2021, 12, 1),
                Value       = 10
            };

            SubsidyCalculation subsidyCalculation = new SubsidyCalculation();

            subsidyCalculation.OnNotify    += OnNotify;
            subsidyCalculation.OnException += OnException;

            Charge charge = subsidyCalculation.CalculateSubsidy(volume, tariff);

            Console.WriteLine($"Subsidy calculation = {charge.Value}\n");
            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Tariff tariff = new Tariff()
            {
                ServiceId = 1, HouseId = 1, PeriodBegin = DateTime.Today, PeriodEnd = DateTime.Now, Value = 10
            };
            Volume volume = new Volume()
            {
                ServiceId = 1, HouseId = 1, Month = DateTime.UtcNow, Value = 10
            };
            SubsidyCalculation subsidyCalculation = new SubsidyCalculation();

            subsidyCalculation.OnNotify    += Notify;
            subsidyCalculation.OnException += Exception;
            Charge charge = subsidyCalculation.CalculateSubsidy(volume, tariff);

            if (charge != null)
            {
                Console.WriteLine($"Расчет: ServiceId - {charge.ServiceId}, " +
                                  $"HouseId - {charge.HouseId}, " +
                                  $"Month - {charge.Month}, " +
                                  $"Value - {charge.Value}");
            }
            else
            {
                Console.WriteLine("Ошибка");
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Tariff tariff = new Tariff
            {
                HouseId     = 1,
                PeriodBegin = new DateTime(2021, 1, 1),
                PeriodEnd   = new DateTime(2022, 1, 1),
                ServiceId   = 5,
                Value       = 10
            };
            Volume volume = new Volume
            {
                HouseId   = 1,
                Month     = new DateTime(2020, 4, 1),
                ServiceId = 5,
                Value     = 100
            };

            SubsidyCalculation sub = new SubsidyCalculation();

            sub.OnException += Handler.Exception;
            sub.OnNotify    += Handler.Notify;
            Charge charge = sub.CalculateSubsidy(volume, tariff);

            Console.WriteLine(charge.Value);
        }
        static void Main(string[] args)
        {
            //Ввод данных тарифа
            var tariff1 = new Tariff();

            tariff1.ServiceId   = 1;
            tariff1.HouseId     = 1;
            tariff1.PeriodBegin = new DateTime(2021, 3, 29);
            tariff1.PeriodEnd   = new DateTime(2021, 5, 29);
            tariff1.Value       = 500;

            //Ввод данных по использованному объему
            var volume1 = new Volume();

            volume1.ServiceId = 1;
            volume1.HouseId   = 1;
            volume1.Month     = new DateTime(2021, 5, 29);
            volume1.Value     = -100;

            //Расчет субсидии
            var subCalcs = new SubsidyCalculation();

            subCalcs.OnNotify    += DisplayMessage;
            subCalcs.OnException += DisplayMessage;

            var chargeResult = subCalcs.CalculateSubsidy(volume1, tariff1);

            Console.WriteLine(chargeResult.Value);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Tariff tariff = new Tariff()
            {
                ServiceId = 1, HouseId = 1, PeriodBegin = DateTime.UtcNow, PeriodEnd = DateTime.UtcNow, Value = -10
            };
            Volume volume = new Volume()
            {
                ServiceId = 1, HouseId = 1, Month = DateTime.UtcNow, Value = 1000
            };
            SubsidyCalculation subsidyCalculation = new SubsidyCalculation();

            try {
                Charge charge = subsidyCalculation.CalculateSubsidy(volume, tariff);
                Console.WriteLine("{0} {1} {2} {3}", charge.ServiceId, charge.HouseId, charge.Month, charge.Value);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error! Message: " + ex.Message);
            }
            Console.ReadLine();
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            var subsidyCalculation = new SubsidyCalculation();

            subsidyCalculation.OnException += WriteMessageAboutException;
            subsidyCalculation.OnNotify    += WriteNotificationAboutCalculation;
            var volume1 = new Volume()
            {
                HouseId   = 1,
                ServiceId = 1,
                Month     = new DateTime(2021, 1, 1),
                Value     = 10
            };
            var tariff1 = new Tariff()
            {
                HouseId     = 1,
                ServiceId   = 1,
                PeriodBegin = new DateTime(2021, 1, 1),
                PeriodEnd   = new DateTime(2021, 3, 31),
                Value       = 2
            };

            subsidyCalculation.CalculateSubsidy(volume1, tariff1);
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            Volume[] volume = new Volume[5];
            ///Данные по использованному объему(подходящие)
            volume[0] = new Volume()
            {
                ServiceId = 1,
                HouseId   = 1,
                Month     = new DateTime(2021, 2, 27),
                Value     = 10
            };
            ///Данные по использованному объему с некорректным идентификатором услуги
            volume[1] = new Volume()
            {
                ServiceId = 2,
                HouseId   = 1,
                Month     = new DateTime(2021, 2, 27),
                Value     = 11
            };
            ///Данные по использованному объему с некорректным идентификатором дома
            volume[2] = new Volume()
            {
                ServiceId = 1,
                HouseId   = 1,
                Month     = new DateTime(2021, 2, 27),
                Value     = 12
            };
            ///Данные по использованному объему с некорректным месяцем
            volume[3] = new Volume()
            {
                ServiceId = 1,
                HouseId   = 1,
                Month     = new DateTime(2021, 3, 27),
                Value     = 13
            };
            ///Данные по использованному объему с некорректным значением
            volume[4] = new Volume()
            {
                ServiceId = 1,
                HouseId   = 1,
                Month     = new DateTime(2021, 2, 27),
                Value     = -14
            };

            Tariff[] tariff = new Tariff[2];
            ///Данные подходящего тарифа
            tariff[0] = new Tariff()
            {
                ServiceId   = 1,
                HouseId     = 1,
                PeriodBegin = new DateTime(2021, 2, 1),
                PeriodEnd   = new DateTime(2021, 2, 28),
                Value       = 100
            };
            ///Данные тарифа со значением 0
            tariff[1] = new Tariff()
            {
                ServiceId   = 1,
                HouseId     = 1,
                PeriodBegin = new DateTime(2021, 2, 1),
                PeriodEnd   = new DateTime(2021, 2, 28),
                Value       = 0
            };


            ///Расчет
            SubsidyCalculation Subsidy = new SubsidyCalculation();

            Subsidy.OnNotify    += dispOnNotify;
            Subsidy.OnException += dispOnException;

            Charge charge;

            charge = Subsidy.CalculateSubsidy(volume[0], tariff[0]);
            Console.WriteLine(charge.Value);
        }