Example #1
0
        public void UpdateGadget(Gadget gadget)
        {
            // Copy gadget, otherwise binding would change displayed data
            Gadget copyGadget = new Gadget
            {
                InventoryNumber = gadget.InventoryNumber,
                Name            = gadget.Name,
                Price           = gadget.Price,
                Condition       = gadget.Condition,
                Manufacturer    = gadget.Manufacturer
            };

            NewEditGadgetWindow singleGadgetWindow = new NewEditGadgetWindow(copyGadget);

            if (singleGadgetWindow.ShowDialog() == true)
            {
                // Copy back
                gadget.InventoryNumber = copyGadget.InventoryNumber;
                gadget.Name            = copyGadget.Name;
                gadget.Price           = copyGadget.Price;
                gadget.Condition       = copyGadget.Condition;
                gadget.Manufacturer    = copyGadget.Manufacturer;

                if (_service.UpdateGadget(gadget))
                {
                    LoadServerData();
                }
                else
                {
                    throw new Exception("Update Gadget Failed!");
                }
            }
            copyGadget = null;
        }
Example #2
0
        public void saveGadget(Gadget modifiedGadget)
        {
            Gadget gadget = SelectedGadget;

            AllGadgets.Insert(allGadgets.IndexOf(modifiedGadget), gadget);
            allGadgets.Remove(modifiedGadget);
            service.UpdateGadget(gadget);
        }
Example #3
0
        internal void UpdateGadget(GadgetViewModel editGadgetViewModel)
        {
            var existingGadget = Gadgets.FirstOrDefault(g => g.InventoryNumber == editGadgetViewModel.InventoryNumber);

            if (existingGadget != null)
            {
                existingGadget.Name         = editGadgetViewModel.Name;
                existingGadget.Condition    = editGadgetViewModel.Condition;
                existingGadget.Price        = editGadgetViewModel.Price;
                existingGadget.Manufacturer = editGadgetViewModel.Manufacturer;

                dataService.UpdateGadget(editGadgetViewModel.Data);
            }
        }
Example #4
0
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            var gadgetToEdit = (Gadget)DgGadgets.SelectedItem;
            var dialog       = new GadgetDialog(gadgetToEdit);

            dialog.ActionText.Text = "Gadget ändern";
            dialog.Title           = "Gadget bearbeiten";
            if (dialog.ShowDialog() == false)
            {
                return;
            }
            _service.UpdateGadget(gadgetToEdit);
            LoadData();
            DgGadgets.SelectedItem = gadgetToEdit;
        }
Example #5
0
        /// <summary>
        /// demonstrates the use of the admin functions to add/remove
        /// new objects to/from the gadgeothek
        /// </summary>
        public void ShowAdminInteraction()
        {
            var service = new LibraryAdminService(ServerUrl);

            var gadget = new Gadget("XBOX360")
            {
                Manufacturer = "Microsoft"
            };

            if (!service.AddGadget(gadget))
            {
                Console.WriteLine($"{gadget} konnte nicht hinzugefügt werden...");
                return;
            }

            var gadgets = service.GetAllGadgets();

            PrintAll(gadgets, "Gadgets (NEW)");

            gadget.Condition = Condition.Damaged;
            if (!service.UpdateGadget(gadget))
            {
                Console.WriteLine($"{gadget} konnte nicht aktualisiert werden...");
                return;
            }


            gadgets = service.GetAllGadgets();
            PrintAll(gadgets, "Gadgets (NEW 2)");

            if (!service.DeleteGadget(gadget))
            {
                Console.WriteLine($"{gadget} konnte nicht gelöscht werden...");
                return;
            }

            gadgets = service.GetAllGadgets();
            PrintAll(gadgets, "Gadgets (NEW 3)");
        }
Example #6
0
 public bool UpdateGadget(Gadget gadget)
 {
     return(Service.UpdateGadget(gadget));
 }
Example #7
0
        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;
        }
Example #8
0
 private void Update()
 {
     libraryAdminService.UpdateGadget(SelectedGadget);
 }