/// <summary> /// Ændrer et udstyr /// </summary> public async void EditMethod() { if (SelectedEquipment != null || SelectedEquipment.Uid > 0) { SelectedEquipment.Type = TypeOfEquipment; await Singleton.Instance.EQP.UpdateEquipment(SelectedEquipment.Uid, SelectedEquipment); var messageDialogue = new MessageDialog($"Udstyr: {SelectedEquipment} er blevet opdateret"); messageDialogue.Commands.Add(new UICommand("Luk")); await messageDialogue.ShowAsync(); } else { var messageDialogue = new MessageDialog($"Vælg et udstyr før du kan opdatere det"); messageDialogue.Commands.Add(new UICommand("Close")); await messageDialogue.ShowAsync(); } ObsEquipment.Clear(); ConvertToObs(); }
/// <summary> /// Fjerner et udstyr /// </summary> public async void DeleteEquipMethod() { if (SelectedEquipment != null) { ListOfErrors = Singleton.Instance.ERP.GetErrors().Result; foreach (Error e in ListOfErrors) { if (SelectedEquipment.Uid == e.Uid) { await Singleton.Instance.ERP.DeleteError(e.Fid); } } switch (SelectedEquipment.Type) { case "Computer": await Singleton.Instance.COM.DeleteComputer(SelectedEquipment.Uid); await Singleton.Instance.EQP.DeleteEquipment(SelectedEquipment.Uid); var messageDialogue1 = new MessageDialog($"En computer er blevet fjernet"); messageDialogue1.Commands.Add(new UICommand("Luk")); await messageDialogue1.ShowAsync(); break; case "Smartboard": await Singleton.Instance.SB.DeleteSmartboard(SelectedEquipment.Uid); await Singleton.Instance.EQP.DeleteEquipment(SelectedEquipment.Uid); var messageDialogue2 = new MessageDialog($"Et smartboard er blevet fjernet"); messageDialogue2.Commands.Add(new UICommand("Luk")); await messageDialogue2.ShowAsync(); break; case "Smartphone": await Singleton.Instance.SP.DeleteSmartphone(SelectedEquipment.Uid); await Singleton.Instance.EQP.DeleteEquipment(SelectedEquipment.Uid); var messageDialogue3 = new MessageDialog($"En smartphone er blevet fjernet"); messageDialogue3.Commands.Add(new UICommand("Luk")); await messageDialogue3.ShowAsync(); break; case "Tablet": await Singleton.Instance.TAB.DeleteTablet(SelectedEquipment.Uid); await Singleton.Instance.EQP.DeleteEquipment(SelectedEquipment.Uid); var messageDialogue4 = new MessageDialog($"En tablet er blevet fjernet"); messageDialogue4.Commands.Add(new UICommand("Luk")); await messageDialogue4.ShowAsync(); break; } } else { var messageDialogue = new MessageDialog($"Vælg et udstyr før du kan fjerne det"); messageDialogue.Commands.Add(new UICommand("Luk")); await messageDialogue.ShowAsync(); } ObsEquipment.Clear(); ConvertToObs(); }
/// <summary> /// Tilføjer et udstyr /// </summary> public async void AddEquipment() { if (TypeOfEquipment == "Computer" || TypeOfEquipment == "Smartboard" || TypeOfEquipment == "Smartphone" || TypeOfEquipment == "Tablet") { Equipment e = new Equipment(TypeOfEquipment); await Singleton.Instance.EQP.CreateEquipment(e); AllEquipment = Singleton.Instance.EQP.GetEquipments().Result; Equipment NewlyCreatedEquip = AllEquipment.Last(); switch (TypeOfEquipment) { case "Computer": Computer pc = new Computer(NewlyCreatedEquip.Uid); await Singleton.Instance.COM.CreateComputer(pc); var messageDialogue1 = new MessageDialog($"En computer er tilføjet"); messageDialogue1.Commands.Add(new UICommand("Luk")); await messageDialogue1.ShowAsync(); break; case "Smartboard": SmartBoard sb = new SmartBoard(NewlyCreatedEquip.Uid); await Singleton.Instance.SB.CreateSmartboard(sb); var messageDialogue2 = new MessageDialog($"Et smartboard er tilføjet"); messageDialogue2.Commands.Add(new UICommand("Luk")); await messageDialogue2.ShowAsync(); break; case "Smartphone": SmartPhone sp = new SmartPhone(NewlyCreatedEquip.Uid); await Singleton.Instance.SP.CreateSmartphone(sp); var messageDialogue3 = new MessageDialog($"En smartphone er tilføjet"); messageDialogue3.Commands.Add(new UICommand("Luk")); await messageDialogue3.ShowAsync(); break; case "Tablet": Tablet tab = new Tablet(NewlyCreatedEquip.Uid); await Singleton.Instance.TAB.CreateTablet(tab); var messageDialogue4 = new MessageDialog($"En tablet er tilføjet"); messageDialogue4.Commands.Add(new UICommand("Luk")); await messageDialogue4.ShowAsync(); break; default: break; } } else { throw new ArgumentException("TypeOfEquipment is null"); } ObsEquipment.Clear(); ConvertToObs(); }