Esempio n. 1
0
 public bool DeleteGadget(Gadget obj)
 {
     if (obj != null)
         return DeleteItem(obj, obj.InventoryNumber);
     else
         return false;
 }
 public void addGadget(String name, Double price, String Manufacturer)
 {
     Gadget gadget = new Gadget(name);
     gadget.Price = price;
     gadget.Manufacturer = Manufacturer;
     Service.AddGadget(gadget);
 }
 private void NewGadgetButton_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var gadget = new Gadget("")
         {
             Condition = (domain.Condition) InputComboCondition.SelectionBoxItem,
             Manufacturer = InputGadgetManufactruer.Text,
             Price = Parse(InputGadgetPrice.Text),
             Name = InputGadgetName.Text
         };
         Service.AddGadget(gadget);
     }
     catch (InvalidCastException)
     {
         MessageBox.Show("Wähle Condition", "Error Adding Gadget", MessageBoxButton.OK);
     }
     catch (FormatException)
     {
         MessageBox.Show("Price als Nummer angeben", "Error Adding Gadget", MessageBoxButton.OK);
     }
     catch (Exception)
     {
         MessageBox.Show("Bitte alle Felder ausfüllen", "Error Adding Gadget", MessageBoxButton.OK);
     }
 }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            String ServerUrl = "http://localhost:8080";
            var service = new LibraryAdminService(ServerUrl);

            // Create Gadget
            String value = this.tbPrice.Text;
            Double result = 0;
            try
            {
                result = Convert.ToDouble(value);
            }
            catch (FormatException)
            {
                Console.WriteLine("Unable to convert '{0}' to a Double.", value);
            }
            catch (OverflowException)
            {
                Console.WriteLine("'{0}' is outside the range of a Double.", value);
            }
            ch.hsr.wpf.gadgeothek.domain.Condition condition = new ch.hsr.wpf.gadgeothek.domain.Condition();
            switch (cbCondition.Text.ToUpper())
            {
                case "NEW":
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.New;
                    break;
                case "GOOD":
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.Good;
                    break;
                case "DAMAGED":
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.Damaged;
                    break;
                case "WASTE":
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.Waste;
                    break;
                case "LOST":
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.Lost;
                    break;
                default:
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.New;
                    break;
            }

            Gadget newGadget = new Gadget();

            string invetoryNr = "0";
            if (!this.tbID.Text.Equals(""))
            {
                invetoryNr = this.tbID.Text;
            }
            newGadget.InventoryNumber = invetoryNr;
            newGadget.Name = this.tbName.Text;
            newGadget.Manufacturer = this.tbManufacturer.Text;
            newGadget.Price = result;
            newGadget.Condition = condition;

            service.UpdateGadget(newGadget);
            this.DialogResult = true;
        }
Esempio n. 5
0
        public bool ReserveGadgetForCustomer(Gadget gadget)
        {
            CheckToken();

            var parameter = PrepareDictionaryWithToken();
            parameter.Add("gadgetId", gadget.InventoryNumber);

            return CallRestApi<bool>("/public/reservations", Method.POST, parameter);
        }
Esempio n. 6
0
 public Loan(String id, Gadget gadget, Customer customer, DateTime? pickupDate, DateTime? returnDate)
 {
     Id = id;
     GadgetId = gadget.InventoryNumber;
     Gadget = gadget;
     CustomerId = customer.Studentnumber;
     Customer = customer;
     PickupDate = pickupDate;
     ReturnDate = returnDate;
 }
Esempio n. 7
0
 public Loan(String id, Gadget gadget, Customer customer, DateTime?pickupDate, DateTime?returnDate)
 {
     Id         = id;
     GadgetId   = gadget.InventoryNumber;
     Gadget     = gadget;
     CustomerId = customer.Studentnumber;
     Customer   = customer;
     PickupDate = pickupDate;
     ReturnDate = returnDate;
 }
        public deleteGadget(Gadget gadget)
        {
            this.gadget = gadget;
            InitializeComponent();

            InventoryNr.Text = gadget.InventoryNumber;
            Condition.Text = gadget.Condition.ToString();
            Price.Text = gadget.Price.ToString();
            Manufacturer.Text = gadget.Manufacturer;
            Name.Text = gadget.Name;
        }
 private void okButton_Click(object sender, RoutedEventArgs e)
 {
     double price;
     Gadget gadget = new Gadget
     {
         Condition = (ch.hsr.wpf.gadgeothek.domain.Condition) conditionComboBox.SelectedValue,
         Manufacturer = manufacturerTextBox.Text,
         InventoryNumber = idTextBlock.Text,
         Name = nameTextBox.Text
     };
     double.TryParse(priceTextBox.Text, out price);
     gadget.Price = price;
     GadgetViewModel model = new GadgetViewModel(_service, gadget);
     _parentWindow.GadgetList.Add(model);
     Close();
 }
Esempio n. 10
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            myGadget = new Gadget();
            myGadget.Name = NameInput.Text;
            myGadget.Manufacturer = ManufacturerInput.Text;
            myGadget.Price = double.Parse(PriceInput.Text);
            //there is a method of Enum -> Enum.Parse that can parse string directly to Condition Enums
            //you wouldn't need a condition mapper
            myGadget.Condition = conditionMapper(ConditionInput.SelectedIndex);
            myGadget.InventoryNumber = INInput.Text;
            WindowMain mainWindow = (WindowMain)Application.Current.MainWindow;
            mainWindow.alibService.AddGadget(myGadget);
            mainWindow.RefreshDataGrid();
            this.Close();

        }
Esempio n. 11
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     Gadget gadget = new Gadget(name.Text.ToString());
     double isDouble;
     double.TryParse(price.Text.ToString(), out isDouble);
     gadget.Price = isDouble;
     gadget.Manufacturer = manufacturer.Text.ToString();
     LibraryAdminService service = new LibraryAdminService(ConfigurationSettings.AppSettings.Get("server"));
     if (service.AddGadget(gadget))
     {
         MessageBox.Show("Gadget successfully added!");
         this.Close();
     }
     else
     {
         MessageBox.Show("Operation failed!");
     }
 }
Esempio n. 12
0
        static void Main(string[] args)
        {
            var url = "http://*****:*****@hsr.ch", "20151113");
            sample.ShowAdminInteractionWithGenericInterface(
                max,
                // get id (student number)
                x => x.Studentnumber,
                // change something
                x => x.Name = "Moritz der 1.");
            

            sample.ShowUserInteraction();


            Console.WriteLine("<Press Any Key to Terminate the App>");
            Console.ReadKey();
        }
 public GadgetViewModel(LibraryAdminService service, Gadget gadget)
 {
     _service = service;
     _gadget = gadget;
 }
        private int GetWaitingPosition(Gadget item)
        {
            int waitingPosition = -1;
            foreach (Reservation res in _service.GetAllReservations())
            {
                if (((res.Gadget != null && res.Gadget.InventoryNumber == item.InventoryNumber)
                        || (res.GadgetId == item.InventoryNumber))
                        && waitingPosition < res.WaitingPosition) {
                    waitingPosition = res.WaitingPosition;
                }
            }

            return waitingPosition + 1;
        }
Esempio n. 15
0
 public AddGadgetModel()
 {
     Gadget = new Gadget("");
 }
 internal void DeleteGadget(Gadget toDelete)
 {
     Gadgets.Remove(toDelete);
     Service.DeleteGadget(toDelete);
 }
 public void addGadget(Gadget gadget)
 {
     Gadgets.Add(gadget);
     Service.AddGadget(gadget);
 }
 public void DeleteSelectedGadget(Gadget gadget)
 {
     MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure?", "Delete Confirmation", MessageBoxButton.YesNo);
     if (messageBoxResult == MessageBoxResult.Yes)
     {
         Service.DeleteGadget(gadget);
     }
 }
 public bool UpdateGadget(Gadget obj)
 {
     return UpdateItem(obj, obj.InventoryNumber);
 }
 private void GadgetGrid_OnSelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
 {
     if (_editingGadget != null)
     {
         Service.UpdateGadget(_editingGadget);
         _editingGadget = null;
     }
 }
 public bool DeleteGadget(Gadget obj)
 {
     return DeleteItem(obj, obj.InventoryNumber);
 }
 public bool AddGadget(Gadget obj)
 {
     return AddItem(obj);
 }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            String value = this.tbPrice.Text;
            Double result = 0.0;
            try
            {
                result = Convert.ToDouble(value);
            }
            catch (FormatException)
            {
                Console.WriteLine("Unable to convert '{0}' to a Double.", value);
            }
            catch (OverflowException)
            {
                Console.WriteLine("'{0}' is outside the range of a Double.", value);
            }

            ch.hsr.wpf.gadgeothek.domain.Condition condition = new ch.hsr.wpf.gadgeothek.domain.Condition();
            switch (cbCondition.Text.ToUpper())
            {
                case "NEW":
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.New;
                    break;
                case "GOOD":
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.Good;
                    break;
                case "DAMAGED":
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.Damaged;
                    break;
                case "WASTE":
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.Waste;
                    break;
                case "LOST":
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.Lost;
                    break;
                default:
                    condition = ch.hsr.wpf.gadgeothek.domain.Condition.New;
                    break;
            }

            Gadget newGadget = new Gadget();
            newGadget.InventoryNumber = findInventoryNumber();
            newGadget.Name = this.tbName.Text;
            newGadget.Manufacturer = this.tbManufacturer.Text;
            newGadget.Price = result;
            newGadget.Condition = condition;

            service.AddGadget(newGadget);
            this.DialogResult = true;
            this.Close();
        }
 private void GadgetGrid_OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
 {
     _editingGadget = e.Row.Item as Gadget;
 }