public void DisplayCart(Customer customer) { List <Ticket> listCart = new List <Ticket>(); try { listCart = ReadFileToListCart(customer); if (listCart.Count != 0) { var table = new ConsoleTable("Ma Ve", "Loai Ve", "Gia", "So Luong"); foreach (var item in listCart) { string ticketprice = pricevalid(item.TicketPrice); table.AddRow(item.TicketID, item.TicketType, ticketprice, item.Amount); } table.Write(Format.Default); } } catch (System.NullReferenceException) { Console.WriteLine("Chua tao gio hang!Moi quay tro lai menu de mua hang"); Console.WriteLine("An phim bat ky de quay tro lai menu mua hang"); Console.ReadKey(); m.MenuTicket(customer); } if (listCart.Count == 0) { Console.WriteLine("Gio hang trong!Moi quay tro lai menu de mua hang"); Console.WriteLine("An phim bat ky de quay tro lai menu mua hang"); Console.ReadKey(); m.MenuTicket(customer); } }
public void BuyTicket(Customer customer) { bool checkchoice = false; while (true) { Console.Clear(); Ticket t = new Ticket(); List <Ticket> listticket = new List <Ticket>(); DisplayMatchDetails(customer); string path = Path.GetFullPath("DataCart" + customer.Username + ".txt"); string choice; if (File.Exists(path) == true) { listticket = ReadFile(customer); } t = InputTicketInfo(customer); foreach (var item in listticket) { if (t.TicketID == item.TicketID) { item.Amount += t.Amount; t = null; break; } } if (t != null) { listticket.Add(t); } if (InputTicketOnFile(customer, listticket) == true) { Console.Write("Them vao gio hang thanh cong!Ban co muon mua tiep khong?(C/K)"); choice = Console.ReadLine().ToUpper(); checkchoice = m.Choose(choice); if (checkchoice == true) { continue; } else { m.MenuTicket(customer); break; } } else { Console.WriteLine("Them vao gio hang khong thanh cong,An phim bat ky de tro ve menu"); Console.ReadKey(); m.MenuTicket(customer); break; } // InputTicketOnFile(customer, listticket); } }