Exemplo n.º 1
0
        public string paymentList(string[] results, DbController dbc, OrderController oc, LocationController lc, Client kliens)
        {
            int i = 0;

            string payment = "Fizetett jegyek\n";

            payment += "--------------------------------\n";
            double sum = 0;

            Dictionary <string, int> events = new Dictionary <string, int>();

            for (int j = 0; j < results.Length; j += 2)
            {
                events[results[j]] = 0;
            }

            for (int j = 0; j < results.Length; j += 2)
            {
                events[results[j]] += 1;
            }
            Order order;
            Seat  seat;

            while (i < results.Length)
            {
                order = kliens.MyOrder.getOrder(Convert.ToInt32(results[i]));
                seat  = order.getSeat(Convert.ToInt32(results[i + 1]));

                oc.getOrder(order.Perform, order.Loc, order.Start).getSeat(seat.RowNumber, seat.ColumnNumber).SeatStatus = "fizetett";

                payment += order.Perform + ", " + order.Loc + ", " + order.Start + ", " + seat.RowNumber + ". sor " + seat.ColumnNumber + ". oszlop\n";
                payment += "Ára: " + lc.findLocationByName(order.Loc).Price + "Ft\n\n";

                sum += lc.findLocationByName(order.Loc).Price;

                seat.SeatStatus = "fizetett";
                dbc.payTicket(kliens.UserID, seat.RowNumber, seat.ColumnNumber);

                i += 2;
            }

            foreach (KeyValuePair <string, int> entry in events)
            {
                if (entry.Value >= 4)
                {
                    payment += "Kedvezmény! A(z) " + kliens.MyOrder.getOrder(Convert.ToInt32(entry.Key)).Perform + " rendezvényre " + entry.Value + " darab jegyet vett, így 20% kedvezményt kap rájuk!\n";
                    double kedvezmeny = lc.findLocationByName(kliens.MyOrder.getOrder(Convert.ToInt32(entry.Key)).Loc).Price *entry.Value * 0.2;

                    payment += "Kedvezmény összege: " + kedvezmeny + "Ft\n";
                    sum     -= kedvezmeny;
                }
            }

            payment += "Összesen: " + sum + "Ft\n";

            return(payment);
        }