Exemplo n.º 1
0
        public T?GetById <T>(string key)
            where T : class
        {
            var def = Activator.CreateInstance(typeof(T));

            return(def switch
            {
                Ticket _ => (Tickets.FirstOrDefault(x => x.Id == key) as T),
                Day _ => (Days.FirstOrDefault(x => x.Id == key) as T),
                Hall _ => (Halls.FirstOrDefault(x => x.Id == key) as T),
                _ => null
            });
Exemplo n.º 2
0
 private void yesBTN_Click(object sender, EventArgs e)
 {
     Validation();
     if (errorTB.Text == string.Empty)
     {
         Rent.Customer   = Customers.FirstOrDefault(c => c.FullName == (string)custCB.SelectedItem);
         Rent.CustomerID = Rent.Customer.ID;
         Rent.Hall       = Halls.FirstOrDefault(h => h.Name == (string)hallCB.SelectedItem);
         Rent.HallID     = Rent.Hall.ID;
         Rent.People     = Convert.ToInt32(peopleNUM.Value);
         Rent.Hours      = Convert.ToInt32(durationNUM.Value);
         Rent.TimeStart  = datestartDTP.Value.Date;
         Rent.TimeStart  = Rent.TimeStart.AddHours(Convert.ToInt32(timestartNUM.Value));
         Rent.Price      = Rent.Hall.Price * Rent.Hours;
         Rent.Customer.CountVisits++;
         Rent.Customer.MoneySpent += Rent.Price;
         DialogResult              = DialogResult.Yes;
     }
 }
Exemplo n.º 3
0
        private void hallCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            Hall hall = Halls.FirstOrDefault(h => h.Name == (string)hallCB.SelectedItem);

            peopleNUM.Maximum = hall.Capacity;
        }