Esempio n. 1
0
 public Item(ItemDm dm)
 {
     Id         = dm.Id;
     Name       = dm.Name;
     Price      = dm.Price;
     AidKitType = AidKitType;
 }
Esempio n. 2
0
        private void SubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(NameTB.Text))
            {
                MessageBox.Show("Name must be specified", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            var item = new ItemDm {
                Name       = NameTB.Text,
                Price      = string.IsNullOrEmpty(PriceTB.Text) ? null : (float?)float.Parse(PriceTB.Text),
                AidKitType = AidKit.Nope
            };

            if (SmallAidKitCB.IsChecked != null && SmallAidKitCB.IsChecked.Value)
            {
                item.AidKitType = AidKit.Small;
            }
            else if (BigAidKitCB.IsChecked != null && BigAidKitCB.IsChecked.Value)
            {
                item.AidKitType = AidKit.Big;
            }

            ItemService.Instance.Add(item);

            if (EventCB.SelectedIndex != -1)
            {
                var ev = events[EventCB.SelectedIndex];
                ReservationService.Instance.Add(
                    new ReservationDm {
                    EventId = ev.Id,
                    ItemId  = item.Id
                });
                if (item.Price != null)
                {
                    // TODO add to event finance
                }
            }
            else
            {
                if (item.Price != null)
                {
                    // TODO add to finance
                }
            }
        }