コード例 #1
0
        protected override async Task OnDelete(Member item)
        {
            var confirm = await DisplayAlert("Delete", $"Delete {item.Name}?", "Yes", "No");

            if (confirm)
            {
                var parameters = new Dictionary <string, string>();
                parameters.Add("teamId", ParentElement?.Id);
                parameters.Add("email", item.Email);
                bool res = false;
                try
                {
                    res = await App.CloudClient.InvokeApiAsync <bool>("Operations/DeleteMember", HttpMethod.Delete, parameters);
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
                if (res)
                {
                    await ParentVM.LoadItems();

                    Team = await ParentVM.GetItem(ParentElement.Id);

                    VM.UpdateFilter(m => Team.Members.Select(tm => tm.Id).Contains(m.Id));
                    await VM.LoadItems();
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Look for a shown child and replace it with a new one
 /// <para>This comes as we have set it up for items to be replaced in the hierarchy</para>
 /// </summary>
 /// <param name="shown">Shown item to replace</param>
 /// <param name="newItem">New item to replace the shown with</param>
 private void ReplaceShownChild(ListItemVM shown, ListItemVM newItem)
 {
     if (ParentItemVM == null)
     {
         if (ParentVM != null)
         {
             ParentVM.ReplaceSelectedItem(newItem);
         }
     }
     else
     {
         if (String.Equals(Model.Code.ChildType, IcdCodeStrings.ChildType_Direct))
         {
             ParentItemVM.ReplaceShownChild(shown, newItem);
         }
         else
         {
             var newParentChildren = ParentItemVM.Children.ToList();
             for (int childOn = 0; childOn < newParentChildren.Count; ++childOn)
             {
                 if (Object.ReferenceEquals(newParentChildren[childOn], shown) ||
                     Object.ReferenceEquals(newParentChildren[childOn], this))
                 {
                     newParentChildren[childOn] = newItem;
                 }
             }
             ParentItemVM.Children = newParentChildren;
         }
     }
 }
コード例 #3
0
        public void ForwardChangeNotificationToParents_WhenParentsChangingDuringNotification_DoesntThrowException()
        {
            var parent = new ParentVM();
            var child  = new ChildVM();

            parent.SetValue(x => x.Child, child);

            child.TriggerChange();
        }
コード例 #4
0
        private void dodajSkladnikAkcja()
        {
            ElementGrid pTest = null;

            if (ParentVM.listaSkladnikow.Count > 0)
            {
                try
                {
                    pTest = ParentVM.listaSkladnikow.First(x => x.NAZWA == nazwa);
                }
                catch (Exception)
                {
                    pTest = null;
                }
            }
            if (pTest == null)
            {
                EntityMethods en = new EntityMethods();
                Skladniki     s  = new Skladniki();
                s.NAZWA        = nazwa;
                s.OPIS         = opis;
                s.UWAGI        = uwagi;
                s.ID_KATEGORII = en.idKategoriiSkladnika(kategorieSelection);
                if (isEdit)
                {
                    s.ID_SKLADNIKA = (int)idEdytowanegoSkladnika;
                    if (zdjecie.GetType() == typeof(BitmapImage))
                    {
                        string path  = ((BitmapImage)zdjecie).UriSource.OriginalString;
                        byte[] image = File.ReadAllBytes(path);
                        s.ZDJECIE = image;
                    }
                    else
                    {
                        s.ZDJECIE = null;
                    }
                    en.edytujSkladnik(s);
                }
                else
                {
                    string path  = ((BitmapImage)zdjecie).UriSource.OriginalString;
                    byte[] image = File.ReadAllBytes(path);
                    s.ZDJECIE = image;
                    idEdytowanegoSkladnika = en.dodajSkladnik(s);
                }
                CloseAction();
                ParentVM.wypiszSkladniki(idEdytowanegoSkladnika);
            }
            else
            {
                MessageBoxShow mb = new MessageBoxShow();
                mb.pokazMessageBox("Informacja", "Został już dodany taki składnik.", MessageBoxTyp.Normalny, MessageBoxIkona.Informacyjna);
            }
        }
コード例 #5
0
 public void OverlayOk()
 {
     if (_errored)
     {
         // Clear overlay and allow re-submit if an error occured.
         OverlayControl = null;
     }
     else
     {
         // If the overlay was a success overlay, switch back to login.
         ParentVM.SwitchToLogin();
     }
 }
コード例 #6
0
        public void DependencyOnDescendant_WhenDescendantIsNotLoaded_DoesNotTriggerLoad()
        {
            var parentVM = new ParentVM(
                b => b
                .OnChangeOf
                .Descendant(x => x.ChildVM)
                .Execute((vm, args) => { })
                );

            parentVM.GetValue(x => x.ChangeTrigger).SetValue(x => x.Name, "ChangeTrigger");

            Assert.IsFalse(parentVM.IsLoaded(x => x.ChildVM));
        }
コード例 #7
0
        public void DependencyOnDescendentPropertiesWithRefreshAction_WhenDescendentIsNull_DoesntThrowException()
        {
            var parentVM = new ParentVM(
                b => b
                .OnChangeOf
                .Properties(x => x.ChangeTrigger)
                .Refresh
                .Descendant(x => x.ChildVM)
                .Properties(x => x.Name)
                );

            parentVM.ChangeTrigger = true;
        }
コード例 #8
0
        [TestMethod] // regression test
        public void SetValue_WhenOldChildGetsInvalidAndNewChildIsValid_ParentValidationResultIsValid()
        {
            var parent = new ParentVM();

            var oldChild = new ChildVM();
            var newChild = new ChildVM();

            parent.SetValue(x => x.Child, oldChild);

            oldChild.ChildPropertyErrorMessage = "Old validation error";
            parent.SetValue(x => x.Child, newChild);

            ValidationAssert.IsValid(parent.ValidationResult);
        }
コード例 #9
0
        private void dodajAkcja()
        {
            string kategoria = null;

            if (ParentVM.kategorie.Count > 0)
            {
                try
                {
                    kategoria = ParentVM.kategorie.First(x => x == nazwa);
                }
                catch (Exception)
                {
                    kategoria = null;
                }
            }
            if (kategoria == null || kategoria == nazwaEdytowanejKategorii)
            {
                EntityMethods en    = new EntityMethods();
                int           index = ParentVM.rodzajeKategorii.IndexOf(ParentVM.rodzajeKategoriiSelection);
                if (isEdit)
                {
                    if (index == 0)
                    {
                        en.edytujKategorieSkladnikow(nazwaEdytowanejKategorii, nazwa);
                    }
                    else if (index == 1)
                    {
                        en.edytujKategoriePrzepisow(nazwaEdytowanejKategorii, nazwa);
                    }
                }
                else
                {
                    if (index == 0)
                    {
                        en.dodajKategorieSkladnikow(nazwa);
                    }
                    else if (index == 1)
                    {
                        en.dodajKategoriePrzepisow(nazwa);
                    }
                }
                ParentVM.wypiszKategorie(index);
                CloseAction();
            }
            else
            {
                MessageBoxShow mb = new MessageBoxShow();
                mb.pokazMessageBox("Informacja", "Została już dodana taka kategoria.", MessageBoxTyp.Normalny, MessageBoxIkona.Informacyjna);
            }
        }
コード例 #10
0
        public void SetValue_ToNewChild_RevalidatesOldAndNewChild()
        {
            var vm       = new ParentVM();
            var oldChild = new ChildVM();
            var newChild = new ChildVM();

            vm.SetValue(x => x.Child, oldChild);

            oldChild.ChildPropertyErrorMessage = "Old validation error";
            newChild.ChildPropertyErrorMessage = "New validation error";

            vm.SetValue(x => x.Child, newChild);

            ValidationAssert.ErrorMessages(oldChild.ValidationResult, oldChild.ChildPropertyErrorMessage);
            ValidationAssert.ErrorMessages(newChild.ValidationResult, newChild.ChildPropertyErrorMessage);
        }
コード例 #11
0
        public void SetValue_RemovesValidationErrorsOfAncestorValidatorsFromOldChild()
        {
            string parentErrorMessage = "Parent error";

            var vm       = new ParentVM();
            var oldChild = new ChildVM();
            var newChild = new ChildVM();

            vm.ChildPropertyErrorMessage = parentErrorMessage;

            vm.SetValue(x => x.Child, oldChild);
            ValidationAssert.ErrorMessages(oldChild.ValidationResult, parentErrorMessage);

            vm.SetValue(x => x.Child, newChild);

            ValidationAssert.IsValid(oldChild);
        }
コード例 #12
0
        public void ToString_WhenCaptionSourceReturnsNull_ReturnsEmptyString()
        {
            var source = new SelectionSource {
                Caption = null
            };
            var vm = new ParentVM {
                AllItemsSource     = new[] { source },
                SelectedItemSource = source
            };

            string caption = vm
                             .GetValue(x => x.Selection)
                             .SelectedItem
                             .ToString();

            Assert.AreEqual(String.Empty, caption);
        }
コード例 #13
0
        public void BaseSetup()
        {
            Results = new ValidatorMockConfigurationFluent();
            var initialState = Results.GetState();

            ChildDescriptor = ChildVM.ClassDescriptor;
            ItemDescriptor  = ItemVM.ClassDescriptor;

            Item        = new ItemVM(Results);
            Child       = new ChildVM(Results);
            Parent      = new ParentVM(Results);
            Grandparent = new GrandparentVM(Results);

            Child.GetValue(x => x.Items).Add(Item);
            Parent.SetValue(x => x.Child, Child);
            Grandparent.GetValue(x => x.Children).Add(Parent);

            initialState.RestoreToState();
        }
コード例 #14
0
        [TestMethod] // regression test
        public void SetValue_WhenOldAndNewChildGetInvalid_ParentResultContainsOnlyErrorOfNewChild()
        {
            var parent = new ParentVM();

            var oldChild = new ChildVM();
            var newChild = new ChildVM();

            parent.SetValue(x => x.Child, oldChild);

            oldChild.ChildPropertyErrorMessage = "Old validation error";
            newChild.ChildPropertyErrorMessage = "New validation error";
            parent.SetValue(x => x.Child, newChild);

            ValidationAssert.ErrorMessages(
                parent.ValidationResult,
                ParentVM.ChildInvalidMessage,
                newChild.ChildPropertyErrorMessage
                );
        }
コード例 #15
0
        /// <summary>
        /// Replace a single, selected item
        /// <para>Attempts to propagate to the ListVM of ParentVM or calls ReplaceShownChild when appropriate</para>
        /// </summary>
        /// <param name="newItem">New item to replace the single selected item with</param>
        public void ReplaceSelectedChild(ListItemVM newItem)
        {
            if (newItem == null)
            {
                return;
            }

            if (ParentItemVM == null)
            {
                if (ParentVM != null)
                {
                    ParentVM.ReplaceSelectedItem(newItem);
                }
            }
            else
            {
                ReplaceShownChild(this, newItem);
            }
        }
コード例 #16
0
        [TestMethod] // regression test
        public void SetValue_WhenOldChildGetsSameErrorAsNewChild_ParentValidationResultContainsErrorOfNewChild()
        {
            var parent = new ParentVM();

            var oldChild = new ChildVM();
            var newChild = new ChildVM();

            parent.SetValue(x => x.Child, oldChild);

            string sameValidationError = "Same validation error";

            oldChild.ChildPropertyErrorMessage = sameValidationError;
            newChild.ChildPropertyErrorMessage = sameValidationError;

            parent.SetValue(x => x.Child, newChild);

            ValidationError oldError = oldChild
                                       .ValidationResult
                                       .Errors
                                       .Single();

            ValidationError newError = newChild
                                       .ValidationResult
                                       .Errors
                                       .Single();

            Assert.AreNotSame(oldError, newError);

            bool newErrorIsContained = parent
                                       .ValidationResult
                                       .Errors
                                       .Any(x => Object.ReferenceEquals(x, newError));

            bool oldErrorIsContained = parent
                                       .ValidationResult
                                       .Errors
                                       .Any(x => Object.ReferenceEquals(x, oldError));

            Assert.IsFalse(oldErrorIsContained);
            Assert.IsTrue(newErrorIsContained);
        }
コード例 #17
0
        public ActionResult Index()
        {
            var parent = new ParentVM
            {
                ParName  = "yo!!",
                ChildVms =
                    new List <ChildVM>()
                {
                    new ChildVM {
                        Name = "frst", Other = "ot1"
                    },
                    new ChildVM {
                        Name = "frst1", Other = "ot12"
                    },
                    new ChildVM {
                        Name = "frst2", Other = "ot13"
                    }
                }
            };

            return(View(parent));
        }
コード例 #18
0
 /// <summary>
 /// Attempt to clear the ParentVM ListVM when appropriate.
 /// <para>Will figure if needs to load </para>
 /// </summary>
 public void ClearForParent()
 {
     if (String.Equals(Model.Code.ChildType, IcdCodeStrings.ChildType_Direct))
     {
         if ((ParentVM != null) && (ParentItemVM != null))
         {
             ParentItemVM.ClearToAllChildren();
             if (Object.ReferenceEquals(ParentVM.Items.Items[0], this))
             {
                 ParentVM.ReplaceSelectedItem(ParentItemVM, false);
             }
             else
             {
                 ReplaceShownChild(this, ParentItemVM);
             }
         }
         else if (ParentVM != null)
         {
             ParentVM.ClearToFullList();
         }
     }
 }
コード例 #19
0
        private void dodajAkcja()
        {
            string jednostka = null;

            if (ParentVM.jednostki.Count > 0)
            {
                try
                {
                    jednostka = ParentVM.jednostki.First(x => x == nazwa);
                }
                catch (Exception)
                {
                    jednostka = null;
                }
            }
            if (jednostka == null || jednostka == nazwaEdytowanejJednostki)
            {
                EntityMethods en = new EntityMethods();
                if (isEdit)
                {
                    en.edytujJednostke(nazwaEdytowanejJednostki, nazwa);
                    ParentVM.wypiszJednostki();
                }
                else
                {
                    en.dodajJednostke(nazwa);
                    ParentVM.wypiszJednostki();
                }
                CloseAction();
            }
            else
            {
                MessageBoxShow mb = new MessageBoxShow();
                mb.pokazMessageBox("Informacja", "Została już dodana taka jednostka.", MessageBoxTyp.Normalny, MessageBoxIkona.Informacyjna);
            }
        }
コード例 #20
0
        public async Task <IFeedbackMessage> SubmitForm()
        {
            if (ValidateInput())
            {
                ParentVM.ShowOverlay();

                var returnedMsg = await FeedbackManager.Instance.SendFeedback(this.Message, this.Email, this.Subject, this.Username, this.Attachments.Select(a => a.FeedbackImage));

                if (returnedMsg != null)
                {
                    this.ClearFormAfterSubmit();
                    var imgReadOnlyVM = new FeedbackMessageReadOnlyVM(returnedMsg, this.ParentVM);
                    ParentVM.Messages.Add(imgReadOnlyVM);
                    ParentVM.SwitchToMessageList();
                    return(returnedMsg);
                }
                else
                {
                    ParentVM.HideOverlay();
                    MessageBox.Show(LocalizedStrings.LocalizedResources.FeedbackSendError);
                }
            }
            return(null);
        }
コード例 #21
0
        public void PropagateChildErrors_WithInvalidChildren_ParentHasError()
        {
            var error = "Child records are invalid";

            var validItem   = new ChildVM();
            var invalidItem = new ChildVM();

            var childDescriptor = CreateChildDescriptor(b => b.CheckViewModel(args => {
                if (args.Target == invalidItem)
                {
                    args.AddError("Item error");
                }
            }));

            ParentVM vm = CreateParent(b => b.PropagateChildErrors(error), childDescriptor);

            vm.Children.Add(validItem);
            ValidationAssert.IsValid(vm.ValidationResult);

            vm.Children.Add(invalidItem);
            var actualParentValidationState = vm.GetValidationResult(ValidationResultScope.Self);

            ValidationAssert.ErrorMessages(actualParentValidationState, error);
        }
コード例 #22
0
        /// <summary>
        /// Update Comments and Children according to whether the item is chosen or not
        /// </summary>
        private void UpdateChosen()
        {
            if (IsChosen)
            {
                if (m_Children == null)
                {
                    Children = CodesToItems.GetChildItems(
                        Model.Children
                        .Where(ci => !ParentHasEnabledCode(ci)),
                        ParentVM, this);
                    if (m_Children.Count == 0)
                    {
                        SpecificityComplete = true;
                    }
                    else
                    {
                        if (!String.Equals(m_Children[0].Title.Title, CodesToItems.SpecificityString))
                        {
                            SpecificityComplete = true;
                        }
                    }
                    m_TrueChildren.Clear();
                    m_TrueChildren.AddRange(Children);
                }
                if ((ParentItemVM != null) && (String.Equals(Model.Code.ChildType, Data.IcdCodeStrings.ChildType_Direct)))
                {
                    Comment = ParentItemVM.Comment;
                    ParentItemVM.Comment       = ListItemVM.CommentStart;
                    ParentItemVM.HasOwnComment = false;
                }
            }
            else
            {
                SpecificityComplete = false;
                foreach (var child in m_TrueChildren)
                {
                    child.IsChosen = false;
                }
                m_TrueChildren.Clear();
                if (HasOwnComment)
                {
                    if ((ParentItemVM != null) && (String.Equals(Model.Code.ChildType, Data.IcdCodeStrings.ChildType_Direct)))
                    {
                        ParentItemVM.Comment       = Comment;
                        ParentItemVM.HasOwnComment = true;
                        Comment = CommentStart;
                    }
                }
                Children = null;
            }


            if (ParentVM != null)
            {
                if (ParentItemVM == null)
                {
                    if (IsChosen)
                    {
                        ParentVM.ClearToItem(this);
                    }
                    else
                    {
                        ParentVM.ClearToFullList();
                    }
                }
                else
                {
                    if (String.Equals(Model.Code.ChildType, IcdCodeStrings.ChildType_Direct))
                    {
                        if (IsChosen)
                        {
                            ParentItemVM.ClearChildrenToSelected();
                            ParentItemVM.ReplaceSelectedChild(this);
                        }
                        else
                        {
                            ClearForParent();
                        }
                    }
                    ParentVM.UpdateChecks();
                }
            }
        }
コード例 #23
0
 public ActionResult Index(ParentVM model)
 {
     return(View(model));
 }
コード例 #24
0
 public void Setup()
 {
     Parent = new ParentVM();
     Assert.IsTrue(Parent.IsValid);
 }
コード例 #25
0
 public void OpenOutputDirectory()
 {
     ParentVM.OpenDirectory(SelectedJob.Options.OutputDir);
 }
コード例 #26
0
ファイル: JobViewModel.cs プロジェクト: elgaspar/SaveTheVid
 public void OpenOutputDirectory()
 {
     ParentVM.OpenDirectory(OutputDir);
 }
コード例 #27
0
        private void dodajPrzepisAkcja()
        {
            EntityMethods en = new EntityMethods();

            ElementGrid pTest = null;

            if (ParentVM.listaPrzepisow.Count > 0)
            {
                try
                {
                    pTest = ParentVM.listaPrzepisow.First(x => x.NAZWA == nazwa);
                }
                catch (Exception)
                {
                    pTest = null;
                }
            }
            if (pTest == null)
            {
                Przepisy p = new Przepisy();
                p.NAZWA        = nazwa;
                p.NOTATKI      = notatki;
                p.OPIS         = opis;
                p.ILOSC_PORCJI = Double.Parse(iloscPorcji);
                p.ID_KATEGORII = en.idKategoriiPrzepisu(kategorieSelection);
                int czas = 0;
                if (czasH != null)
                {
                    czas = Int32.Parse(czasH) * 60 + Int32.Parse(czasM);
                }
                else
                {
                    czas = Int32.Parse(czasM);
                }
                p.CZAS_PRZYRZADZENIA = czas;
                if (isEdit == false)
                {
                    string path  = ((BitmapImage)zdjecie).UriSource.OriginalString;
                    byte[] image = File.ReadAllBytes(path);
                    p.ZDJECIE = image;

                    idEdytowanegoPrzepisu = en.dodajPrzepis(p);
                }
                else
                {
                    if (zdjecie.GetType() == typeof(BitmapImage))
                    {
                        string path  = ((BitmapImage)zdjecie).UriSource.OriginalString;
                        byte[] image = File.ReadAllBytes(path);
                        p.ZDJECIE = image;
                    }
                    else
                    {
                        p.ZDJECIE = null;
                    }

                    p.ID_PRZEPISU = (int)idEdytowanegoPrzepisu;

                    en.edytujPrzepis(p);

                    en.czyscPrzepisySkladniki((int)idEdytowanegoPrzepisu);
                }

                List <Przepisy_Skladniki> lista = new List <Przepisy_Skladniki>();
                foreach (SkladnikPrzepisu sp in listaSkladnikow)
                {
                    Przepisy_Skladniki ps = new Przepisy_Skladniki();
                    ps.L_ID_PRZEPISU = (int)idEdytowanegoPrzepisu;
                    if (sp.ILOSC != null)
                    {
                        ps.ILOSC = sp.ILOSC;
                    }
                    if (!String.IsNullOrWhiteSpace(sp.JEDNOSTKA))
                    {
                        ps.ID_JEDNOSTKI = en.pobierzIdJednostki(sp.JEDNOSTKA);
                    }
                    ps.L_ID_SKLADNIKA = en.idSkladnika(sp.NAZWA);
                    en.dodajPrzepisySkladniki(ps);
                }

                ParentVM.wypiszPrzepisy((int)idEdytowanegoPrzepisu);
                CloseAction();
            }
            else
            {
                MessageBoxShow mb = new MessageBoxShow();
                mb.pokazMessageBox("Informacja", "Został już dodany taki przepis.", MessageBoxTyp.Normalny, MessageBoxIkona.Informacyjna);
            }
        }
コード例 #28
0
 public MyCustomCommand(ParentVM parent, MyTabItemViewModel item)
 {
     Parent = parent;
     Item   = item;
 }
コード例 #29
0
 public MyTabItemViewModel(ParentVM parent)
 {
     MyCommand = new DeleteCommand(parent, this);
 }