public bool UsePestHostControl(AssociateViewModel associate)
        {
            if (associate != null && Preferences.UseSimplifiedAssociates.Value)
            {
                // New associate, or the relationships haven't been set yet - we can use the pest/host control in this case...
                if (string.IsNullOrWhiteSpace(associate.RelationFromTo) && string.IsNullOrWhiteSpace(associate.RelationToFrom))
                {
                    return(true);
                }
                // Otherwise make sure the associate relationships are either Pest or Host only
                if (string.IsNullOrWhiteSpace(associate.RelationFromTo) || string.IsNullOrWhiteSpace(associate.RelationToFrom))
                {
                    return(false);
                }

                if (!associate.RelationFromTo.Equals("pest", StringComparison.CurrentCultureIgnoreCase) && !associate.RelationFromTo.Equals("host", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(false);
                }

                if (!associate.RelationToFrom.Equals("pest", StringComparison.CurrentCultureIgnoreCase) && !associate.RelationToFrom.Equals("host", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
 private void SetRelationships(AssociateViewModel associate)
 {
     if (associate != null)
     {
         associate.RelativeRelationFromTo = optPest.IsChecked.ValueOrFalse() ? "Host" : "Pest";
         associate.RelativeRelationToFrom = optPest.IsChecked.ValueOrFalse() ? "Pest" : "Host";
     }
 }
 private void SetFromPinnable(AssociateViewModel associate, PinnableObject pinnable)
 {
     if (pinnable != null && associate != null)
     {
         var viewModel = PluginManager.Instance.GetViewModel(pinnable);
         associate.RelativeCatID      = TraitCategoryTypeHelper.GetCategoryIDFromLookupType(pinnable.LookupType);
         associate.RelativeIntraCatID = pinnable.ObjectID;
         associate.NameOrDescription  = viewModel.DisplayLabel;
         SetRelationships(associate);
         lblAssociateType.Content = pinnable.LookupType.ToString();
     }
 }
        public ViewModelBase AddNewItem(out DatabaseCommand addAction)
        {
            var model = new Associate();

            model.AssociateID    = -1;
            model.FromIntraCatID = Owner.ObjectID.Value;
            model.FromCategory   = Category.ToString();
            model.Direction      = "FromTo";

            var viewModel = new AssociateViewModel(model);

            addAction = new InsertAssociateCommand(model, Owner);
            return(viewModel);
        }