Ejemplo n.º 1
0
        public void NewTicket(string title, string description)
        {
            Ticket userTicket = new Ticket(title, description);

            Tickets.Add(userTicket);
            Messages.Add(new Message(ConsoleColor.Green, "Successfully Created"));
        }
Ejemplo n.º 2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var result = await Service.GetAll();

            result.ForEach(x => Tickets.Add(x));
            lastId = Tickets.LastOrDefault().Id;
        }
Ejemplo n.º 3
0
 private async void BtnCreate_OnClick(object sender, RoutedEventArgs e)
 {
     Сanvas.Visibility = Visibility.Collapsed;
     if (isCreate)
     {
         var ticket = ReadTextBoxesData();
         if (ticket != null)
         {
             try
             {
                 await Service.Create(ticket);
             }
             catch
             {
                 Info.Text = "Server error!";
             }
             lastId++;
             ticket.Id = lastId;
             Tickets.Add(ticket);
             isCreate = false;
             CreateInfo();
             Info.Text = "Choose new action!";
         }
     }
     else
     {
         CreateInfo();
         isCreate  = true;
         Info.Text = "Info : Input data and press 'Create' ";
     }
 }
Ejemplo n.º 4
0
        private void LoadData()
        {
            string inputFile = AppDomain.CurrentDomain.BaseDirectory + @"..\..\input.txt";

            if (File.Exists(inputFile))
            {
                string       line;
                StreamReader file = new StreamReader(inputFile);
                // read the rules first
                while ((line = file.ReadLine()) != null)
                {
                    if (line.Length > 1)
                    {
                        ParseRule(line);
                    }
                    else
                    {
                        break;
                    }
                }
                line       = file.ReadLine();
                line       = file.ReadLine();
                YourTicket = ParseTicket(line);
                line       = file.ReadLine(); // blank
                line       = file.ReadLine(); // "nearby tickets"
                while ((line = file.ReadLine()) != null)
                {
                    Tickets.Add(ParseTicket(line));
                }

                file.Close();
            }
        }
Ejemplo n.º 5
0
 // Method adding Ticket
 public void AddTicket(LotteryTicket ticket)
 {
     if (ticket != null)
     {
         Tickets.Add(ticket);
     }
 }
Ejemplo n.º 6
0
        //SellDoubleTickets(person01 : Person, person02 : Person, int seatNumber, fee decimal) : Ticket[]
        public Ticket[] SellDoubleTickets(Person person01, Person person02, int seatNumber, decimal fee)
        {
            Ticket[] doubleTickets = new Ticket[2];
            decimal  minAmount     = (IsEmployee(person01) || IsEmployee(person02)) ?
                                     Route.Baseprice : Route.Baseprice * 1.05m;

            if (fee < minAmount * 2)
            {
                throw new ArgumentOutOfRangeException(nameof(fee));
            }
            if (isAvalailableForDouble(seatNumber))
            {
                if (seatNumber % 3 == 0)
                {
                    doubleTickets[0] = new Ticket(this, GetSeatInformation(seatNumber - 1), person01, fee / 2);
                    doubleTickets[1] = new Ticket(this, GetSeatInformation(seatNumber), person02, fee / 2);
                }
                else
                {
                    doubleTickets[0] = new Ticket(this, GetSeatInformation(seatNumber), person01, fee / 2);
                    doubleTickets[1] = new Ticket(this, GetSeatInformation(seatNumber + 1), person02, fee / 2);
                }
                Tickets.Add(doubleTickets[0]);
                Tickets.Add(doubleTickets[1]);
            }
            return(doubleTickets);
        }
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Tickets.Clear();
                var tickets = App.MerchandisingTicketData.GetAllTickets();
                foreach (var ticket in tickets)
                {
                    Tickets.Add(ticket);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 8
0
        public int AddTicketViewModel(int selectedNdx)
        {
            if (SelectedCategoryType == null || DataService.ElectionId == Guid.Empty)
            {
                return(selectedNdx);
            }

            TicketViewModel cvm = new TicketViewModel()
            {
                Id         = Guid.NewGuid(),
                ElectionId = DataService.ElectionId,
                CategoryId = Id
            };

            int nextNdx = selectedNdx <= 0 ? 1 :
                          selectedNdx == (Tickets.Count - 1) ? nextNdx                     = Tickets.Count :
                                                                                   nextNdx = selectedNdx + 1;

            cvm.Sequence = nextNdx;
            for (int n = nextNdx; n < Tickets.Count; n++)
            {
                Tickets[n].Sequence = n + 1;
            }
            Tickets.Add(cvm);
            RefreshTickets();
            return(selectedNdx);
        }
Ejemplo n.º 9
0
 public void VoegTicketToe(Ticket ticket)
 {
     if (ticket != null)
     {
         Tickets.Add(ticket);
     }
 }
Ejemplo n.º 10
0
        private void Refresh()
        {
            Tickets.Clear();

            if (!String.IsNullOrEmpty(SearchId))
            {
                try
                {
                    Ticket ticket = _context.Tickets.Find(Convert.ToInt32(SearchId));

                    if (ticket != null)
                    {
                        Tickets.Add(ticket);
                    }
                }
                catch (FormatException)
                {
                    MessageBoxService.Show("Bad id format", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                var tickets = _context.Tickets.ToList();

                foreach (var ticket in tickets)
                {
                    Tickets.Add(ticket);
                }
            }
        }
Ejemplo n.º 11
0
        public async void Delete(object sender, RoutedEventArgs e)
        {
            if (SaveButton.Visibility == Visibility.Visible)
            {
                SaveButton.Visibility = Visibility.Collapsed;
            }

            if (AddButton.Visibility == Visibility.Visible)
            {
                AddButton.Visibility = Visibility.Collapsed;
            }

            try
            {
                if (TextId.IsReadOnly)
                {
                    TextId.IsReadOnly = false;
                }

                await _service.Delete(SelectedTicket.Id.ToString());

                // refresh listView
                Tickets.Clear();
                foreach (var airplaneType in await _service.LoadData())
                {
                    Tickets.Add(airplaneType);
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 12
0
        public async Task BookFlight(Passenger passenger, Flight flight)
        {
            //check available space
            var plane = await Planes.Include(a => a.Model).FirstOrDefaultAsync(a => a.Id == flight.PlaneId);

            var tickets = await Tickets.Where(a => a.FlightId == flight.Id).ToListAsync();

            if (plane.Model.Capacity < tickets.Count)
            {
                throw new Exception("Not enough space in a plane.");
            }

            if (tickets.Any(a => a.PassengerId == passenger.Id))
            {
                throw new Exception("A passenger can only book one ticket per flight");
            }

            Tickets.Add(new Ticket()
            {
                Flight    = flight,
                Passenger = passenger
            });

            await SaveChangesAsync();
        }
Ejemplo n.º 13
0
        public void LoadTickets()
        {
            Tickets.Clear();
            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = CONNECTION_STRING;
                conn.Open();

                SqlCommand command = conn.CreateCommand();
                command.CommandText = @"SELECT * FROM Tickets";

                SqlDataAdapter daTickets = new SqlDataAdapter();
                DataSet        dsTickets = new DataSet();

                daTickets.SelectCommand = command;
                daTickets.Fill(dsTickets, "Tickets");

                foreach (DataRow row in dsTickets.Tables["Tickets"].Rows)
                {
                    Tickets ticket = new Tickets();

                    ticket.Id          = (int)row["Id"];
                    ticket.FlightNum   = GetFlightNumber((string)row["FlightNum"]);
                    ticket.SeatClass   = (EClass)row["SeatClass"];
                    ticket.SeatNum     = GetSeatLabel((string)row["SeatNum"]);
                    ticket.CurrentUser = (string)row["CurrentUser"];
                    ticket.Gate        = (string)row["Gate"];
                    ticket.TicketPrice = (decimal)row["TicketPrice"];
                    ticket.Active      = (bool)row["Active"];

                    Tickets.Add(ticket);
                }
            }
        }
Ejemplo n.º 14
0
        public void AddTicket(Passenger passenger, int seats, DateTime date)
        {
            Ticket ticket = new Ticket($"{Number}-{(Tickets.Count + 1).ToString("000")}", passenger, Vehicle, Route, seats, date);

            Tickets.Add(ticket);
            ValueOfTickets += ticket.Total;
        }
 private void Method1()
 {
     Tickets.Add(new Билеты()
     {
         IDСеанса = App.A, IDЗала = _ctx.Сеансы.FirstOrDefault(k => k.ID == App.A).IDЗала, Место = SelectedPlace, яд = SelectedRow, Бронь = false
     });
     RaisePropertyChanged("Ticket");
 }
Ejemplo n.º 16
0
        private async void Create()
        {
            var created = await airportConnector.TicketEndpoint.Create(newTicket);

            Tickets.Add(created);
            newTicket = new Ticket();
            RaisePropertyChanged(() => Tickets);
            RaisePropertyChanged(() => NewTicket);
        }
Ejemplo n.º 17
0
        public void AddTicket(Ticket ticket)
        {
            if (Tickets == null)
            {
                Tickets = new List <Ticket>();
            }

            Tickets.Add(ticket);
        }
Ejemplo n.º 18
0
        private async void FillAdditionalCollections()
        {
            var tickets = await TService.GetEntities();

            foreach (var item in tickets)
            {
                Tickets.Add(item);
            }
        }
Ejemplo n.º 19
0
        private async void FillTicketsCollection()
        {
            var temp = await service.GetEntities();

            foreach (var item in temp)
            {
                Tickets.Add(item);
            }
        }
Ejemplo n.º 20
0
        internal Ticket addTicket(TicketSerializer ticket)
        {
            Customer    c = GetCustomer(ticket.CId);
            Reservation r = null; // Just for now
            Ticket      t = new Ticket(ticket, c, r);

            Tickets.Add(t);
            this.SaveChanges();
            return(t);
        }
Ejemplo n.º 21
0
 protected void AddTicket(int id, DateTime?dateClosed, DateTime dateOpened, int assignedToId = 1)
 {
     Tickets.Add(new Ticket
     {
         Id           = id,
         DateClosed   = dateClosed,
         DateOpened   = dateOpened,
         AssignedToId = assignedToId
     });
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Loads Order Tickets
        /// </summary>
        /// <param name="order">Order</param>
        private void LoadCustomerAndOrderTickets(Order order)
        {
            if (order.CustomerId > 0)
            {
                Customer       = Access.GetCustomer(order.CustomerId);
                CustomerEmail  = Customer.Email;
                CustomerName   = Customer.Name;
                LastName       = Customer.LastName;
                FirstName      = Customer.FirstName;
                MiddleName     = Customer.MiddleName;
                CustomerPhone  = Customer.Phone;
                Customer.Order = order;
            }

            Ticket[] tickets = Access.GetTickets(order.Id);
            if (tickets != null)
            {
                OrderPrice =
                    tickets.Where(x => x.Status == ItemStatus.Reserved || x.Status == ItemStatus.Sold).Sum(x => x.Price);
                Ticket firstTicket = tickets.FirstOrDefault();
                if (firstTicket != null)
                {
                    ReserveDate = firstTicket.ReserveDate;
                }
                if (tickets.Count() < 10)
                {
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        foreach (Ticket ticket in tickets)
                        {
                            MemoryStream ms = GetTicketImage(order.Id, ticket.Id, 1);
                            if (ms != null)
                            {
                                Ticket t       = ticket;
                                BitmapImage bi = new BitmapImage();
                                bi.BeginInit();
                                bi.StreamSource = ms;
                                bi.EndInit();
                                t.TicketImage = bi;
                            }
                        }
                    });
                }

                Application.Current.Dispatcher.Invoke((Action) delegate
                {
                    Tickets.Clear();
                    foreach (Ticket t in tickets)
                    {
                        Ticket ticket = t;
                        Tickets.Add(ticket);
                    }
                });
            }
        }
Ejemplo n.º 23
0
        //Method to add new tickets fot the player
        public void AddNewTicket(int drawID)
        {
            var kinoBonusOption = RandomNumbersMachine.TossCoin();
            var ticket          = new Ticket(drawID, kinoBonusOption);

            foreach (var num in ChosenNumbers)
            {
                ticket.AddNumberPlayed(num);
            }
            Tickets.Add(ticket);
        }
Ejemplo n.º 24
0
        public async Task Search()
        {
            Tickets.Clear();

            List <Ticket> tempTickets = await TicketService.GetAll();

            foreach (var item in tempTickets)
            {
                Tickets.Add(item);
            }
        }
Ejemplo n.º 25
0
        public override Tickets Tickets(DateRange dateRange)
        {
            Excuses excuses = Excuses.FromFile("Excuse.txt");
            var     tickets = new Tickets();
            IEnumerable <DateTime> weekDays = dateRange.Days().Where(d => !d.IsWeekend());

            foreach (DateTime day in weekDays)
            {
                tickets.Add(day, excuses.RandomExcuse());
            }

            return(tickets);
        }
Ejemplo n.º 26
0
 public void Load(string filename)
 {
     using (StreamReader reader = new StreamReader(filename, Encoding.UTF8))
     {
         while (reader.Peek() >= 0)
         {
             var line = reader.ReadLine().Trim();
             if (line == "")
             {
                 continue;
             }
             Tickets.Add(TicketEntity.FromCSV(line));
         }
     }
 }
Ejemplo n.º 27
0
        private void AddReservation()
        {
            TicketType type = null;

            if (TicketTypes.Count() > 0)
            {
                type = TicketTypes.First();
            }
            Tickets.Add(new Ticket()
            {
                Amount       = 1,
                TicketHolder = "Nieuwe koper",
                Type         = type
            });
        }
        private void InitTickets()
        {
            Ticket ticket1 = new Ticket();
            Ticket ticket2 = new Ticket();

            ticket1.Id         = 1;
            ticket1.Coupons[0] = Coupons.Find(f => f.Id == 1);
            ticket1.Coupons[1] = Coupons.Find(f => f.Id == 3);
            ticket2.Id         = 2;
            ticket2.Coupons[0] = Coupons.Find(f => f.Id == 2);
            Tickets.Add(ticket1);
            Tickets.Add(ticket2);
            Coupons.Find(c => c.Id == 1).Ticket = ticket1;
            Coupons.Find(c => c.Id == 2).Ticket = ticket2;
            Coupons.Find(c => c.Id == 3).Ticket = ticket1;
        }
Ejemplo n.º 29
0
        //get active tickets from webservice
        public void getActiveTicketsFromWebservice()
        {
            //clear list
            Tickets.Clear();

            Webservice Service = new Webservice();

            if (_ParkingPlaceForTicketSelect != null)
            {
                Service.getActiveTickets(_ParkingPlaceForTicketSelect.id);
                for (int i = 0; i < Service.TicketList.Count; i++)
                {
                    Tickets.Add(Service.TicketList.ElementAt(i));
                }
            }
        }
Ejemplo n.º 30
0
 public bool CreateTicket(Ticket ticket, string userId)
 {
     try
     {
         if (!Tickets.Items.Any(x => x.Name == ticket.Name.Trim() && x.RentalId == ticket.RentalId))
         {
             ticket.Name        = ticket.Name.Trim();
             ticket.UserCreated = userId;
             Tickets.Add(ticket);
             return(true);
         }
     }
     catch (Exception e)
     {
     }
     return(false);
 }