public void Execute(OptionAttempt attempt) { Console.WriteLine("\nOption 5. Order Movie Tickets"); this.attempt = attempt; List <Ticket> ticketList = new List <Ticket>(); Order order = new Order(); order.Status = "Unpaid"; int movieIndex = Select.Movie(attempt) - 1; Screening session = SelectSession(movieIndex); int numOfTickets = GetNoOfTicket(session); CheckMovieClassification(movieIndex); // Ordering of tickets for (int i = 1; i <= numOfTickets; i++) { Console.WriteLine("\nTicket #" + i); // Hand resposibility over to TicketFactory Ticket ticket = TicketFactory.CreateTicket(GetTicketType(), session, attempt); order.AddTicket(ticket); } session.SeatsRemaining -= numOfTickets; PrintOrderSummary(order, session); }
public void firstInitialize() { ClientFactory clientFactory = new ClientFactory(); ClientGateway <Client> cg = (ClientGateway <Client>)clientFactory.GetClient(); TrainingFactory trainingFactory = new TrainingFactory(); TrainingGateway <Training> tg = (TrainingGateway <Training>)trainingFactory.GetTraining(); DiscountFactory discountFactory = new DiscountFactory(); DiscountGateway <DiscountCard> dg = (DiscountGateway <DiscountCard>)discountFactory.GetCard(); PurchaseFactory purchaseFactory = new PurchaseFactory(); PurchaseGateway <Purchase> pg = (PurchaseGateway <Purchase>)purchaseFactory.GetPurchase(); TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); Client client = cg.Select(tg.SelectLast().ClientId); clientName.Text = client.ToString(); if (client.CardId != null) { int toSetId = client.CardId ?? default(int); card = dg.Select(toSetId); } Ticket t = ticketg.Select(pg.SelectLast(card.RecordId).TicketId); ticketType.Text = t.Type; credit.Text = card.Credit.ToString(); }
/// <summary> /// Customer can upgrade thier seat by using Tickect Handler Controller. /// </summary> /// <param name="myTicket"></param> public void UpgradeTicket(Ticket myTicket, string typeOfTicket) { TicketFactory ticketProvider = null; Ticket myNewTicket = null; switch (typeOfTicket) { case "Economy": ticketProvider = new EconomyTicketFactory(); break; case "PremiunEconomy": ticketProvider = new PremiumEconomyTicketFactory(); break; case "Business": ticketProvider = new BusinessTicketFactory(); break; } myNewTicket = ticketProvider.GetTicket(); myTicket.TicketType = myNewTicket.TicketType; myTicket.IsCancellationInsuranceApplied = myNewTicket.IsCancellationInsuranceApplied; myTicket.CancellationDuration = myNewTicket.CancellationDuration; myTicket.UserInsurance = myNewTicket.UserInsurance; Console.WriteLine("---Successfully Upgraded the seat---"); Console.WriteLine("Your Seat Level now is '{0}'.", myTicket.TicketType); Console.WriteLine("-------------------------------------"); }
public static void Main(string[] args) { Console.WriteLine("Which vehicle you would travel? Please choose one"); Console.WriteLine("1.Bus \n2.Train \n3.Plane"); var ticketType = Convert.ToInt32(Console.ReadLine()); Console.Write("Please Enter FromCity: "); var fromCity = Console.ReadLine(); Console.Write("Please Enter ToCity: "); var toCity = Console.ReadLine(); if (ticketType == 1) { var ticket = new TicketFactory().getTicket(1); ticket.BuyTicket(DateTime.Now, fromCity, toCity); } else if (ticketType == 2) { var ticket = new TicketFactory().getTicket(2); ticket.BuyTicket(DateTime.Now, fromCity, toCity); } else if (ticketType == 3) { var ticket = new TicketFactory().getTicket(3); ticket.BuyTicket(DateTime.Now, fromCity, toCity); } Console.Read(); }
//Restore button private void restoreToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you really want to restore data from XML? Almost all online data will be lost.", "Restore", MessageBoxButtons.YesNo) == DialogResult.Yes) { LockerFactory lockerFactory = new LockerFactory(); LockerGateway <Locker> lg = (LockerGateway <Locker>)lockerFactory.GetLocker(); TrainingFactory trainingFactory = new TrainingFactory(); TrainingGateway <Training> tg = (TrainingGateway <Training>)trainingFactory.GetTraining(); PurchaseFactory purchaseFactory = new PurchaseFactory(); PurchaseGateway <Purchase> pg = (PurchaseGateway <Purchase>)purchaseFactory.GetPurchase(); TrainerFactory trainerFactory = new TrainerFactory(); TrainerGateway <Trainer> trainerg = (TrainerGateway <Trainer>)trainerFactory.GetTrainer(); TrainerRatingFactory trainerRatingFactory = new TrainerRatingFactory(); TrainerRatingGateway <TrainerRating> tr = (TrainerRatingGateway <TrainerRating>)trainerRatingFactory.GetTrainerRating(); TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); tg.Delete(); pg.Delete(); tr.Delete(); trainerg.Delete(); lg.Delete(); ticketg.Delete(); foreach (var locker in lg.Select()) { lg.Insert(locker); } foreach (var ticket in TicketXMLGateway <Ticket> .Instance.Select()) { TicketXMLGateway <Ticket> .Instance.Insert(ticket); } foreach (var trainer in TrainerXMLGateway <Trainer> .Instance.Select()) { TrainerXMLGateway <Trainer> .Instance.Insert(trainer); } foreach (var purchase in PurchaseXMLGateway <Purchase> .Instance.Select()) { PurchaseXMLGateway <Purchase> .Instance.Insert(purchase); } foreach (var training in TrainingXMLGateway <Training> .Instance.Select()) { TrainingXMLGateway <Training> .Instance.Insert(training); } foreach (var rating in TrainerRatingXMLGateway <TrainerRating> .Instance.Select()) { TrainerRatingXMLGateway <TrainerRating> .Instance.Insert(rating); } MessageBox.Show("Data restored!"); } }
protected override bool DeleteRecord() { TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); ticketg.Delete(ticket.RecordId); return(true); }
/// <summary> /// Implementation for your slot. /// </summary> /// <param name="signaler">Signaler used to raise the signal.</param> /// <param name="input">Arguments to your slot.</param> public void Signal(ISignaler signaler, Node input) { // This will throw is ticket is expired, doesn't exist, etc. TicketFactory.VerifyTicket(_ticketProvider, null); // Retrieving old ticket and using its data to create a new ticket. input.Value = TicketFactory.CreateTicket(_configuration, TicketFactory.GetTicket(_ticketProvider)); }
public void CreateTicket_creates_ticket_with_requested_title(TicketFactory sut, CreateTicketRequest request) { // Act var result = sut.CreateTicket(request); // Assert Assert.That(result.Title, Is.EqualTo(request.Title)); }
public void CreateTicket_creates_ticket_with_requested_description(TicketFactory sut, CreateTicketRequest request) { // Act var result = sut.CreateTicket(request); // Assert Assert.That(result.Description, Is.EqualTo(request.Description)); }
/// <summary> /// Implementation for the slots. /// </summary> /// <param name="signaler">Signaler used to raise the signal.</param> /// <param name="input">Arguments to your signal.</param> public void Signal(ISignaler signaler, Node input) { var ticket = TicketFactory.GetTicket(_ticketProvider); input.Value = ticket.Username; if (ticket.Roles.Any()) { input.Add(new Node("roles", null, ticket.Roles.Select(x => new Node("", x)))); } }
public async Task <WxConfig> GetConfig(string url) { string ticket = await TicketFactory.GetTicketAsync(); if (string.IsNullOrEmpty(ticket)) { return(null); } return(WxConfig.Create(_options, ticket, url)); }
static void Main(string[] args) { TicketFactory ltf = new TicketFactory("C:\\key.pem"); LoginTicket mrNobody = new LoginTicket("Вася", 60 * 24); string result = ltf.CreateTicket(mrNobody); Console.WriteLine("Login ticket is:"); Console.WriteLine(result); Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
protected override void RefreshData() { TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); Collection <Ticket> tickets = ticketg.Select(); BindingList <Ticket> bindingList = new BindingList <Ticket>(tickets); ticketsGrid.AutoGenerateColumns = false; ticketsGrid.DataSource = bindingList; }
public TicketApplicationServiceTests() { fakeTicketRepository = new FakeTicketRepository(); fakeTicketCategoryRepository = new FakeTicketCategoryRepository(); domainNotificationHandler = new DomainNotificationHandler(); factory = new TicketFactory(); fakeServiceBus = new FakeServiceBus(); uow = new FakeUnitOfWork(); identityResolver = new FakeIdentityResolver(); applicationService = new TicketApplicationService(fakeTicketRepository, fakeTicketCategoryRepository, factory, identityResolver, domainNotificationHandler, uow, fakeServiceBus); }
private void inputPaymentBtn_Click(object sender, RoutedEventArgs e) { string paymentStr = paymentTxt.Text.Trim(); int payment; bool success = int.TryParse(paymentStr, out payment); if (!success) { errorLbl.Text = "Payment must be a number!"; } else { int change = totalPrice - payment; if (change > 0) { errorLbl.Text = "Payment is not enough!"; } else { TicketMediator mediator = new TicketMediator(); TicketFactory factory = new TicketFactory(); changeLbl.Text = "Change = \t\tRp. " + Math.Abs(change).ToString(); ticketList = new List <Ticket>(); for (int i = 0; i < quantity; i++) { ticketList.Add(mediator.addTicket(factory.generateTicket())); } TicketTransactionMediator tmediator = new TicketTransactionMediator(); TicketTransactionFactory tfactory = new TicketTransactionFactory(); foreach (Ticket ticket in ticketList) { TicketTransaction transaction = tmediator.addTicketTransaction(tfactory.createNewTicketTransaction(ticket.ticketID)); if (transaction == null) { MessageBox.Show("Buy ticket failed!"); return; } } MessageBox.Show("Buy ticket success!"); nextBarcodeBtn.Visibility = Visibility.Visible; qr = new QRCode(ticketList.ElementAt(counter)); qr.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; qr.Show(); } } }
public static long Part1() { var lines = FileReader.ReadInputLines(Day).ToList(); // 3 groups = rules, yours, others var groups = lines.Split("").Select(l => l.ToList()).ToList(); var ticketFactory = new TicketFactory(groups[0]); var tickets = ticketFactory.BuildTickets(groups[2]); return(tickets.Sum(t => t.GetErrorValues().Sum())); return(tickets.Count(t => !t.Validate())); }
/// <summary> /// Implementation for the slots. /// </summary> /// <param name="signaler">Signaler used to raise the signal.</param> /// <param name="input">Arguments to your signal.</param> public void Signal(ISignaler signaler, Node input) { var username = input.Children.FirstOrDefault(x => x.Name == "username")?.GetEx <string>() ?? throw new ArgumentException("No [username] supplied to [auth.ticket.create]"); var roles = input.Children .FirstOrDefault(x => x.Name == "roles")? .Children .Select(x => x.GetEx <string>()) .ToArray(); input.Clear(); input.Value = TicketFactory.CreateTicket(_configuration, new Ticket(username, roles)); }
public TicketItem CreateTicket(string prefix) { lock (_locker) { var inseartPlase = (ushort)GetInseartPlace(prefix); var ticket = TicketFactory.Create(inseartPlase, prefix); var priority = Prefixes.FirstOrDefault(p => p.Name == prefix)?.Priority; if (priority.HasValue) { ticket.Priority = priority.Value; } return(ticket); } }
public void CreateTicket_marks_ticket_with_current_utc_timestamp([Frozen] IEnvironment environment, DateTime now, TicketFactory sut, CreateTicketRequest request) { // Arrange Mock.Get(environment) .Setup(x => x.GetCurrentUtcTimestamp()) .Returns(now); // Act var result = sut.CreateTicket(request); // Assert Assert.That(result.CreationTimestamp, Is.EqualTo(now)); }
static void Main(string[] args) { #region Initialize logger var logRepository = LogManager.GetRepository(System.Reflection.Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new System.IO.FileInfo("Log4Net.config")); log.Info("Application [FileParser] Start"); #endregion #region Check input data var fileName = Parser.TryGetString(args, 0, out ErrorCode errorCode); if (errorCode != ErrorCode.Void) { Console.WriteLine(errorCode.GetMessage()); return; } if (!File.Exists(fileName)) { Console.WriteLine(NotFound); return; } #endregion try { var ticketType = new FileParser(fileName).GetLuckyType(); Ticket ticket = TicketFactory.Build(ticketType); var count = ticket.GetLuckyCount(); Console.WriteLine("Lucky tickets count:" + count); } catch (Exception e) { log.Error(e); Console.WriteLine(e.Message); } }
protected void RefreshData() { TrainingFactory trainingFactory = new TrainingFactory(); TrainingGateway <Training> tg = (TrainingGateway <Training>)trainingFactory.GetTraining(); TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); ClientFactory clientFactory = new ClientFactory(); ClientGateway <Client> cg = (ClientGateway <Client>)clientFactory.GetClient(); TrainerFactory trainerFactory = new TrainerFactory(); TrainerGateway <Trainer> trainerg = (TrainerGateway <Trainer>)trainerFactory.GetTrainer(); Collection <Training> trainings = tg.Select(); Collection <TrainGrid> trainGrid = new Collection <TrainGrid>(); foreach (Training t in trainings) { TrainGrid tgrid = new TrainGrid(); tgrid.LockerId = t.LockerId; tgrid.ToGender = t.ToGender; tgrid.Start = t.TimeFrom; tgrid.End = t.TimeTo; // using factory to get data Client c = cg.Select(t.ClientId); tgrid.ClientName = c.Name + " " + c.Surname; int tempId; if (t.TrainerId.HasValue) { tempId = t.TrainerId.Value; Trainer tr = trainerg.Select(tempId); tgrid.TrainerName = tr.Name + " " + tr.Surname; } else { tgrid.TrainerName = ""; } trainGrid.Add(tgrid); } BindingList <TrainGrid> bindingList = new BindingList <TrainGrid>(trainGrid); trainingsGrid.AutoGenerateColumns = false; trainingsGrid.DataSource = bindingList; }
public override bool OpenRecord(object primaryKey) { TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); if (primaryKey != null) { int idTicket = (int)primaryKey; ticket = ticketg.Select(idTicket); newRecord = false; } else { ticket = new Ticket(); newRecord = true; } BindData(); return(true); }
public void FactoryShouldReturnTicket() { Guid catId = Guid.NewGuid(); Guid userId = Guid.NewGuid(); TicketFactory factory = new TicketFactory(); //Come from repository TicketCategory category = new TicketCategory(catId, "Problemas de ativação"); //Come from repository LedgerIdentityUser user = new LedgerIdentityUser(userId); Ticket ticket = factory.OpenTicket("Não consigo ativar minha conta", "Falha ao ativar minha conta", category.Id, user.Id); Assert.IsNotNull(ticket); Assert.AreEqual(userId, user.Id); Assert.AreEqual(catId, category.Id); }
public static long Part2() { var lines = FileReader.ReadInputLines(Day).ToList(); // 3 groups = rules, yours, others var groups = lines.Split("").Select(l => l.ToList()).ToList(); var ticketFactory = new TicketFactory(groups[0]); var tickets = ticketFactory.BuildTickets(groups[2]); var validTickets = tickets.Where(t => t.Validate()).ToList(); var lookup = ticketFactory.CalculatePropertyLookup(validTickets); var indexesToCheck = lookup .Where(l => l.Value.StartsWith("departure")) .Select(x => x.Key); var myTicket = ticketFactory.BuildTicket(groups[1][1]); return(indexesToCheck.Aggregate(1L, (a, i) => a * myTicket.Values[i])); }
protected override bool SaveRecord() { TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); if (GetData()) { if (newRecord) { ticketg.Insert(ticket); } else { ticketg.Update(ticket); } return(true); } else { return(false); } }
/// <summary> /// Implementation of slot. /// </summary> /// <param name="signaler">Signaler used to raise the signal.</param> /// <param name="input">Arguments to signal.</param> public void Signal(ISignaler signaler, Node input) { TicketFactory.VerifyTicket(_ticketProvider, input.GetEx <string>()); }
// Use this for initialization void Start() { tf = this.GetComponent <TicketFactory> (); //setPB (P.GetComponent<PlayerBehaviour>()); //UpdateStock (); }
public MoscowTicketAlghorithm(TicketFactory tickets) : base(tickets) { }
private void backupToolStripMenuItem1_Click(object sender, EventArgs e) { LockerFactory lockerFactory = new LockerFactory(); LockerXMLGateway <Locker> lg = (LockerXMLGateway <Locker>)lockerFactory.GetLocker(); TrainingFactory trainingFactory = new TrainingFactory(); TrainingGateway <Training> tg = (TrainingGateway <Training>)trainingFactory.GetTraining(); PurchaseFactory purchaseFactory = new PurchaseFactory(); PurchaseGateway <Purchase> pg = (PurchaseGateway <Purchase>)purchaseFactory.GetPurchase(); TrainerFactory trainerFactory = new TrainerFactory(); TrainerGateway <Trainer> trainerg = (TrainerGateway <Trainer>)trainerFactory.GetTrainer(); TrainerRatingFactory trainerRatingFactory = new TrainerRatingFactory(); TrainerRatingGateway <TrainerRating> tr = (TrainerRatingGateway <TrainerRating>)trainerRatingFactory.GetTrainerRating(); TicketFactory ticketFactory = new TicketFactory(); TicketGateway <Ticket> ticketg = (TicketGateway <Ticket>)ticketFactory.GetTicket(); // Backup button XDocument xDoc = new XDocument(); XElement xRoot = new XElement("Database"); ClientFactory clientFactory = new ClientFactory(); ClientGateway <Client> cg = (ClientGateway <Client>)clientFactory.GetClient(); Collection <Client> clients = cg.Select(); XElement xClients = new XElement("Clients"); foreach (var client in clients) { xClients.Add(ClientXMLGateway <Client> .Instance.Insert(client)); } DiscountFactory discountFactory = new DiscountFactory(); DiscountGateway <DiscountCard> dg = (DiscountGateway <DiscountCard>)discountFactory.GetCard(); Collection <DiscountCard> cards = dg.Select(); XElement xCards = new XElement("Cards"); foreach (var card in cards) { xCards.Add(DiscountXMLGateway <DiscountCard> .Instance.Insert(card)); } Collection <Locker> lockers = lg.Select(); XElement xLockers = new XElement("Lockers"); foreach (var locker in lockers) { xLockers.Add(LockerXMLGateway <Locker> .Instance.Insert(locker)); } Collection <Purchase> purchases = pg.Select(); XElement xPurchases = new XElement("Purchases"); foreach (var purchase in purchases) { xPurchases.Add(PurchaseXMLGateway <Purchase> .Instance.Insert(purchase)); } Collection <Ticket> tickets = ticketg.Select(); XElement xTickets = new XElement("Tickets"); foreach (var ticket in tickets) { xTickets.Add(TicketXMLGateway <Ticket> .Instance.Insert(ticket)); } Collection <TrainerRating> ratings = tr.Select(); XElement xRatings = new XElement("TrainerRatings"); foreach (var rating in ratings) { xRatings.Add(TrainerRatingXMLGateway <TrainerRating> .Instance.Insert(rating)); } Collection <Trainer> trainers = trainerg.Select(); XElement xTrainers = new XElement("Trainers"); foreach (var trainer in trainers) { xTrainers.Add(TrainerXMLGateway <Trainer> .Instance.Insert(trainer)); } Collection <Training> trainings = tg.Select(); XElement xTrainings = new XElement("Trainings"); foreach (var training in trainings) { xTrainings.Add(TrainingXMLGateway <Training> .Instance.Insert(training)); } xRoot.Add(xClients); xRoot.Add(xCards); xRoot.Add(xLockers); xRoot.Add(xPurchases); xRoot.Add(xTickets); xRoot.Add(xRatings); xRoot.Add(xTrainers); xRoot.Add(xTrainings); xDoc.Add(xRoot); if (!Directory.Exists(Connective.Backup.Paths.FolderPath)) { Directory.CreateDirectory(Connective.Backup.Paths.FolderPath); } using (StreamWriter sw = new StreamWriter(Connective.Backup.Paths.FilePath)) { sw.Write(xDoc.ToString()); } MessageBox.Show("Backed up!"); }
public TicketController() { ticketFactory = new TicketFactory(); }