TheAirline.Models.Routes.Route.GetRouteInvoiceAmount C# (CSharp) Method

GetRouteInvoiceAmount() public method

public GetRouteInvoiceAmount ( Invoice type, DateTime startTime, DateTime endTime ) : double
type Invoice
startTime DateTime
endTime DateTime
return double
        public double GetRouteInvoiceAmount(Invoice.InvoiceType type, DateTime startTime, DateTime endTime)
        {
            int startYear = startTime.Year;
            int endYear = endTime.Year;

            int startMonth = startTime.Month;
            int endMonth = endTime.Month;

            int totalMonths = (endMonth - startMonth) + 12*(endYear - startYear);

            double totalAmount = 0;

            var date = new DateTime(startYear, startMonth, 1);

            for (int i = 0; i < totalMonths; i++)
            {
                if (type == Invoice.InvoiceType.Total)
                {
                    totalAmount += Invoices.GetAmount(date.Year, date.Month);
                }
                else
                {
                    totalAmount += Invoices.GetAmount(type, date.Year, date.Month);
                }

                date = date.AddMonths(1);
            }

            return totalAmount;
        }

Same methods

Route::GetRouteInvoiceAmount ( Invoice type ) : double

Usage Example

Ejemplo n.º 1
0
        public HumanRouteMVVM(Route route)
        {
            Route = route;
            ShowCargoInformation = Route.Type == Route.RouteType.Cargo
                                        || Route.Type == Route.RouteType.Mixed;
            ShowPassengersInformation = Route.Type == Route.RouteType.Passenger
                                             || Route.Type == Route.RouteType.Mixed || Route.Type == Route.RouteType.Helicopter;

            IsEditable = true;
            // !this.Route.getAirliners().Exists(a => a.Status != FleetAirliner.AirlinerStatus.Stopped);

            Invoices = new List<MonthlyInvoice>();

            foreach (Invoice.InvoiceType type in Route.GetRouteInvoiceTypes())
            {
                Invoices.Add(new MonthlyInvoice(type, 1950, 1,1, Route.GetRouteInvoiceAmount(type)));
            }

            Legs = new List<Route>();
            Legs.Add(Route);
            Legs.AddRange(Route.Stopovers.SelectMany(s => s.Legs));

            Distance = MathHelpers.GetDistance(Route.Destination1, Route.Destination2);

            setFeedback();
        }