public MasterTargetListViewModel()
 {
     TargetProfiles = new ObservableCollection <PersonModel>();
     AlohomoraServices.RegisterService("MasterTargetListViewModel", this);
     DeleteItemCommand    = new ButtonCommand(CanDeleteItem, DeleteItemExecuted);
     TargetDetailsCommand = new ButtonCommand(CanDisplayTargetDetails, DisplayTargetDetails);
     GetPersonModels();
 }
        public static void SetMapLocation(string address)
        {
            TargetProfileViewModel viewModelInstance = AlohomoraServices.GetService("TargetProfileViewModel") as TargetProfileViewModel;

            if (viewModelInstance != null)
            {
                viewModelInstance.GetLatLong(address);
            }
        }
        public static IEnumerable <PersonModel> GetTargetProfiles()
        {
            MasterTargetListViewModel masterTargetListViewModel = AlohomoraServices.GetService("MasterTargetListViewModel") as MasterTargetListViewModel;

            if (masterTargetListViewModel != null)
            {
                return(masterTargetListViewModel.TargetProfiles);
            }
            else
            {
                return(null);
            }
        }
        public static void SaveTargetProfiles()
        {
            MasterTargetListViewModel masterTargetListViewModel = AlohomoraServices.GetService("MasterTargetListViewModel") as MasterTargetListViewModel;

            string json = Serializer.PersonModelsToJson(masterTargetListViewModel.TargetProfiles);

            if (File.Exists("./cachedTargets.alohomora"))
            {
                File.Delete("./cachedTargets.alohomora");
            }
            File.AppendAllText("./cachedTargets.alohomora", json);
            File.Encrypt("./cachedTargets.alohomora");
        }
        public static void AddTarget(PersonModel model)
        {
            MasterTargetListViewModel masterTargetListViewModel = AlohomoraServices.GetService("MasterTargetListViewModel") as MasterTargetListViewModel;

            if (masterTargetListViewModel != null)
            {
                bool targetExists = masterTargetListViewModel.TargetProfiles.Where(profile => profile.PersonId == model.PersonId).Count() > 0;
                if (!targetExists)
                {
                    masterTargetListViewModel.TargetProfiles.Add(model);
                    masterTargetListViewModel.OnPropertyChanged("TargetProfiles");
                }
            }
        }
        public TargetProfileViewModel(PersonModel targetModel)
        {
            if (targetModel == null)
            {
                throw new Exception("Target Profile cannot be null");
            }
            else
            {
                TargetProfile = targetModel;
                OnPropertyChanged("TargetProfile");
            }

            AddNoteCommand    = new ButtonCommand(CanExecuteAddNoteText, AddNoteTextExecuted);
            DeleteNoteCommand = new ButtonCommand(CanExecuteDeleteNoteText, DeleteNoteTextExecuted);

            AlohomoraServices.RegisterService("TargetProfileViewModel", this);
        }