public ContactDetailViewModel(
            ContactViewModel viewModel,
            IContactStore contactStore,
            IPageService pageService)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            _pageService  = pageService;
            _contactStore = contactStore;

            SaveCommand = new Command(async() => await Save());

            Contact = new Contact
            {
                Id        = viewModel.Id,
                FirstName = viewModel.FirstName,
                LastName  = viewModel.LastName,
                Phone     = viewModel.Phone,
                Email     = viewModel.Email,
                IsBlocked = viewModel.IsBlocked
            };
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor de la clase que se encarga de inicializar el almacenamiento en la BBDD y los servicios de la Page
        /// </summary>
        /// <param name="viewModel">Modelo con el que se comunica la vista.</param>
        /// <param name="contactStore">Controlador donde se alojan los datos.</param>
        /// <param name="pageService">Servicios de la Page de Xamarin.</param>
        public ContactDetailViewModel(ContactViewModel viewModel, IContactStore contactStore, IPageService pageService)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            _pageService  = pageService;
            _contactStore = contactStore;
            //Inicializamos el comando del boton de guardar.
            SaveCommand = new Command(async() => await Save());

            // Here we are mapping our view model to a domain model.
            // This is required because further below where we use ContactStore
            // to add or update a contact, we need a domain model, not a view model.
            // Read my comment in the constructor of ContactViewModel.

            Contact = new Contact
            {
                Id        = viewModel.Id,
                FirstName = viewModel.FirstName,
                LastName  = viewModel.LastName,
                Phone     = viewModel.Phone,
                Email     = viewModel.Email,
                IsBlocked = viewModel.IsBlocked,
            };
        }
Exemplo n.º 3
0
        public ContactsPageViewModel(IContactStore contactStore, IPageService pageService)
        {
            _contactStore = contactStore;
            _pageService  = pageService;


            MessagingCenter.Subscribe <ContactDetailViewModel, Contact>
                (this, Events.ContactAdded, OnContactAdded);

            MessagingCenter.Subscribe <ContactDetailViewModel, Contact>
                (this, Events.ContactUpdated, OnContactUpdated);

            // Subscribe to events
            //MessagingCenter.Subscribe<ContactDetailViewModel, Contact>
            //    (this, Events.ContactAdded, OnContactAdded);

            // Because LoadData is an async method and returns Task, we cannot
            // pass its name as an Action to the constructor of the Command.
            // So, we need to define an inline function using a lambda expression
            // and manually call it using await.
            LoadDataCommand      = new Command(async() => await LoadData());
            AddContactCommand    = new Command(async() => await AddContact());
            SelectContactCommand = new Command <ContactViewModel>(async c => await SelectContact(c));
            DeleteContactCommand = new Command <ContactViewModel>(async c => await DeleteContact(c));
        }
 public static void AddDummyContacts(this IContactStore source, int number)
 {
     foreach (var index in Enumerable.Range(1, number))
     {
         source.Add(new dummyContact(index));
     }
 }
Exemplo n.º 5
0
 public ContactsController(
     IContactStore contactStore,
     ILogger <ContactsController> logger,
     IMapper mapper)
 {
     _contactStore = contactStore;
     _logger       = logger;
     _mapper       = mapper;
 }
Exemplo n.º 6
0
        public ContactsViewModel(IPageService pageService, IContactStore contactStore)
        {
            _pageService  = pageService;
            _contactStore = contactStore;

            AddContactCommand    = new Command(AddContact);
            ViewContactCommand   = new Command <ContactViewModel>(c => ViewContact(c));
            DeleteContactCommand = new Command <ContactViewModel>(c => DeleteContact(c));
        }
        internal Action(IContactStore manager, Contact contact)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            this.manager = manager;
            this.contact = contact;
        }
        public ContactsViewModel(IContactStore contactStore, IPageService pageService)
        {
            _pageService  = pageService;
            _contactStore = contactStore;

            LoadDataCommand      = new Command(async() => await LoadData());
            AddContactoCommand   = new Command(async() => await AddContact());
            SelectContactCommand = new Command <ContactViewModel>(async c => await SelectContact(c));
            DeleteContactCommand = new Command <ContactViewModel>(async c => await DeleteContact(c));
        }
Exemplo n.º 9
0
        public ContactsPageViewModel(IPageService pageService, IContactStore store)
        {
            _pageService  = pageService;
            _contactStore = store;

            LoadDataCommand      = new Command(async() => await LoadData());
            AddContactCommand    = new Command <ContactViewModel>(async vm => await AddContact());
            SelectContactCommand = new Command <ContactViewModel>(async vm => await SelectContact(vm));
            DeleteContactCommand = new Command <ContactViewModel>(async vm => await DeleteContact(vm));
        }
        public ContactsListViewModel(IContactStore contactStore, IPageService pageService)
        {
            _contactStore = contactStore;
            _pageService  = pageService;


            LoadDataCommand   = new Command(async() => await LoadData());
            AddContactCommand = new Command(async() => await AddContact());
            //DeleteContactCommand = new Command(async () => await DeleteContact());
            SearchTextCommand = new Command <String>((searchTxt) => SearchContact(searchTxt));
        }
Exemplo n.º 11
0
 public ContactsPageViewModel(IContactStore contactStore, IPageService pageService)
 {
     _contactStore        = contactStore;
     _pageService         = pageService;
     LoadDataCommand      = new Command(async() => await LoadData());
     AddContactCommand    = new Command(async() => await AddContact());
     SelectContactCommand = new Command <ContactViewModel>(async c => await SelectContact(c));
     DeleteContactCommand = new Command <ContactViewModel>(async c => await DeleteContact(c));
     MessagingCenter.Subscribe <ContactDetailViewModel, Contact>(this, ContactEvents.ContactAdded, OnContactAdded);
     MessagingCenter.Subscribe <ContactDetailViewModel, Contact>(this, ContactEvents.ContactUpdated, OnContactUpdated);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Add a contact to the database.
 /// </summary>
 /// <remarks>Do not alter once handed off</remarks>
 /// <param name="contactToAdd">The contact to add. Don't modify once handed off.</param>
 /// <param name="preferedStorage">Where to store it. If null, stored in default spot</param>
 public void Add(IContact contactToAdd, IContactStore preferedStorage = null)
 {
     if (preferedStorage == null)
     {
         _preferedStore.Add(contactToAdd);
     }
     else
     {
         preferedStorage.Add(contactToAdd);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Add a new contact store to our list. We'll keep everything up to date from it.
        /// </summary>
        /// <param name="s"></param>
        public void Add(IContactStore s)
        {
            if (_preferedStore != null)
            {
                throw new InvalidOperationException("Only one contact store is possible at a time right now!");
            }

            // Connect ourselves to the store. The first thing it should do is send
            // us a complete list of contacts. We'll then forward that on to everyone.
            _preferedStore = s;
            _contactStoreSubscriptions.Add(s.ContactUpdateStream.Subscribe(_contactStoreStream));
        }
Exemplo n.º 14
0
        public ContactsViewModel(IPageService pageService, IContactStore contactStore)
        {
            _pageService  = pageService;
            _contactStore = contactStore;

            AddContactCommand    = new Command(AddContact);
            ViewContactCommand   = new Command <ContactViewModel>(c => ViewContact(c));
            DeleteContactCommand = new Command <ContactViewModel>(c => DeleteContact(c));

            MessagingCenter.Subscribe <ContactsDetailViewModel, Contact>(this, Events.ContactAdded, (source, c) => Contacts.Add(new ContactViewModel(c)));
            MessagingCenter.Subscribe <ContactsDetailViewModel, Contact>(this, Events.ContactUpdated, OnContactUpdated);
        }
        public ContactsPageViewModel(IContactStore contactStore, IPageService pageService)
        {
            _contactStore = contactStore;
            _pageService  = pageService;

            // Because LoadData is an async method and returns Task, we cannot
            // pass its name as an Action to the constructor of the Command.
            // So, we need to define an inline function using a lambda expression
            // and manually call it using await.
            LoadDataCommand      = new Command(async() => await LoadData());
            AddContactCommand    = new Command(async() => await AddContact());
            SelectContactCommand = new Command <ContactViewModel>(async c => await SelectContact(c));
            DeleteContactCommand = new Command <ContactViewModel>(async c => await DeleteContact(c));
        }
Exemplo n.º 16
0
        /// <summary>
        /// Constructor de  la clase, inicializa el almacenamiento en la BBDD asi como el servicio de Page Xamarin.
        /// </summary>
        /// <param name="contactStore">Instancia de la BBDD donde guardar los contactos.</param>
        /// <param name="pageService">Servicio de las Page con acceso a Xamarin.</param>
        public ContactsPageViewModel(IContactStore contactStore, IPageService pageService)
        {
            _contactStore = contactStore;
            _pageService  = pageService;
            //Como LoadData y los demas metodos es async y tiene tipo de retorno Task no podemos pasarle el nombre del metodo como Action al constructor
            //de la clase Command (Xamarin.Forms)tenemos que crear una Inline Action con Lambda y llamarlo manualmente con el Await.
            LoadDataCommand      = new Command(async() => await LoadData().ConfigureAwait(false));
            AddContactCommand    = new Command(async() => await AddContact().ConfigureAwait(false));
            SelectContactCommand = new Command <ContactViewModel>(async c => await SelectContact(c).ConfigureAwait(false));
            DeleteContactCommand = new Command <ContactViewModel>(async c => await DeleteContact(c).ConfigureAwait(false));

            //Subscribimos las propiedades al modelo de la Vista de la Page para eliminar los eventos.
            MessagingCenter.Subscribe <ContactDetailViewModel, Contact>(this, Events.ContactAdded, OnContactAdded);
            MessagingCenter.Subscribe <ContactDetailViewModel, Contact>(this, Events.ContactUpdated, OnContactUpdated);
        }
Exemplo n.º 17
0
        public LoginViewModel(INavigationService _navigation, IDatabase _database,
                              ILogging _logging, IAccountManager _accountManager, IDialogue _dialogue,
                              IMusicManager _musicManager, IContactManager _contactManager, IContactStore _contactStore, IMusicReader _musicStore) : base(_navigation, _database, _logging, _dialogue)
        {
            //Managers
            accountManager = _accountManager;
            musicManager   = _musicManager;
            contactManager = _contactManager;

            //Dependency Services
            contactStore = _contactStore;
            musicStore   = _musicStore;

            //Commands
            ILogin    = new RelayExtension(Login, CanLogin);
            IRegister = new RelayExtension(Register, CanRegister);

            //Social Auth
            IFacebook = new RelayExtension(Facebook, CanFacebook);
            ITwitter  = new RelayExtension(Twitter, CanTwitter);
            ILinkedIn = new RelayExtension(LinkedIn, CanLinkedIn);
            IGoogle   = new RelayExtension(Google, CanGoogle);

            //Request Permissions for services
            CrossPermissions.Current.RequestPermissionsAsync(new Permission[] { Permission.Camera, Permission.Contacts, Permission.Photos });

            //Load Credentials if Remember Me is clicked
            var credentialsStore = Xamarin.Auth.AccountStore.Create();
            var AccountDetails   = credentialsStore.FindAccountsForService(Credentials_Service);

            if (AccountDetails.ToList().Count != 0)
            {
                if (AccountDetails.First().Properties.Any(w => w.Key == "RememberMe"))
                {
                    if (!string.IsNullOrWhiteSpace(AccountDetails.First().Properties.SingleOrDefault(w => w.Key == "RememberMe").Value))
                    {
                        if (AccountDetails.First().Properties.SingleOrDefault(w => w.Key == "RememberMe").Value.Equals("true"))
                        {
                            RememberMe = true;
                            Username   = AccountDetails.First().Username;
                            Password   = "******";
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        public HomeViewModel(INavigationService _navigation, IDatabase _database,
                             ILogging _logging, IToastNotificator toastNotifier,
                             //Managers
                             IAccountManager _accountManager, INotesManager _notesManager, IPhotoVideoManager _photoVideoManager, IPasswordManager _passwordManager,
                             IContactManager _contactManager, IContactStore _contactStore, IDialogue _dialogue) : base(_navigation, _database, _logging, _dialogue)
        {
            //Managers
            accountManager    = _accountManager;
            notesManager      = _notesManager;
            passwordManager   = _passwordManager;
            photoVideoManager = _photoVideoManager;
            contactManager    = _contactManager;

            contactStore = _contactStore;

            //services
            _toastNotifier = toastNotifier;

            //Navigation Drawer Information
            Title = "Home";

            var SiteUser = _accountManager.GetSiteUser_ByID <Cross.DataVault.Data.Account>(Constants.InMemory_ContactID);

            if (SiteUser != null)
            {
                SiteUserEmail = SiteUser.Email;
                SiteUserName  = String.Format("{0} {1}", SiteUser.FirstName, SiteUser.LastName);
                Avatar        = SiteUser.Avatar;
                Initials      = String.Format("{0}{1}", SiteUserName.First().ToString().ToUpper(), SiteUserName.Last().ToString().ToLower());
            }

            //Relays
            IOpenDrawer = new Relays.RelayExtension(OpenDrawer, CanOpenDrawer);
            IOpenSearch = new Relays.RelayExtension(OpenSearch, CanOpenSearch);

            //Relays - Refresh Data
            IOnRefresh = new Relays.RelayExtension(OnRefresh, CanOnRefresh);

            //Refresh Data
            OnRefresh();

            Initialize_Navigation();
            InitializeCards();
        }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ContactManager" /> class.
        /// </summary>
        /// <param name="store">The persistence store the manager will operate over.</param>
        /// <param name="errorDescriber">The <see cref="OperationErrorDescriber" /> used to provider error messages.</param>
        /// <param name="services">The <see cref="IServiceProvider" /> used to resolve services.</param>
        /// <exception cref="System.ArgumentNullException">store</exception>
        public ContactManager(IContactStore store, OperationErrorDescriber errorDescriber, IServiceProvider services = null)
        {
            if (store == null)
            {
                throw new ArgumentNullException(nameof(store));
            }
            if (errorDescriber == null)
            {
                throw new ArgumentNullException(nameof(errorDescriber));
            }

            Store          = store;
            ErrorDescriber = errorDescriber;

            if (services != null)
            {
                _cancellationTokenAccessor = services.GetService(typeof(ICancellationTokenAccessor)) as ICancellationTokenAccessor;
            }
        }
Exemplo n.º 20
0
        public ContactsDetailViewModel(ContactViewModel viewModel, IContactStore contactStore, IPageService pageService)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            _pageService  = pageService;
            _contactStore = contactStore;
            SaveCommand   = new Command(async() => await Save());
            Contact       = new Person
            {
                Id           = viewModel.Id,
                Nombres      = viewModel.Nombres,
                Apellidos    = viewModel.Apellidos,
                DocIdentidad = viewModel.DocIdentidad,
                Telefono1    = viewModel.Telefono1
            };
        }
Exemplo n.º 21
0
        //Initializes loads all contacts from the device and adds them to the collection
        //Allows the ability to add contacts
        public ContactsViewModel(INavigationService _navigation, IDatabase _database, ILogging _logger, IDialogue _dialogue,
                                 IContactManager _contactManager, IAccountManager _accountManager, IContactStore _contactStore) : base(_navigation, _database, _logger, _dialogue)
        {
            contactsManager = _contactManager;
            accountManager  = _accountManager;
            contactStore    = _contactStore;

            //Drawer Details
            Title = "My Contacts";

            //Relays
            IGoBack = new Relays.RelayExtension(GoBack, CanGoBack);

            //Relays - Refresh Data
            IOnRefresh = new Relays.RelayExtension(OnRefresh, CanOnRefresh);

            //Initialize Data & Navigation
            Initialize_Core();
        }
Exemplo n.º 22
0
        public ContactsDetailViewModel(ContactViewModel contact, IPageService pageService, IContactStore contactStore)
        {
            if (contact == null)
            {
                throw new ArgumentNullException(nameof(contact));
            }

            Contact = new Contact
            {
                Id          = contact.Id,
                FirstName   = contact.FirstName,
                Surname     = contact.Surname,
                PhoneNumber = contact.PhoneNumber,
                Email       = contact.Email,
                IsBlocked   = contact.IsBlocked
            };

            Title = Contact.Id == 0 ? "New contact" : "Update contact";

            SaveContactCommand = new Command(SaveContact);

            _pageService  = pageService;
            _contactStore = contactStore;
        }
 public ContactManager(IContactStore contactStore)
 {
     _contactStore = contactStore;
 }
 /// <summary>
 /// Construction with parameter to inject dependancy
 /// </summary>
 /// <param name="store"></param>
 public ContactManagerController(IContactStore store)
 {
     contactStore = store;
 }
 public NzContactCreator(IContactStore contactStore, IRoleStore roleStore, ILog log) : base(contactStore, log)
 {
     _roleStore = roleStore;
 }
 public ContactCreator(IContactStore contactStore, ILog log)
 {
     _contactStore = contactStore;
     _log = log;
 }
Exemplo n.º 27
0
 public Remove(IContactStore manager, Contact contact)
     : base(manager, contact)
 {
 }
 public ContactLister(IContactStore contactStore)
 {
     _contactStore = contactStore;
 }
Exemplo n.º 29
0
 public Add(IContactStore manager, Contact contact)
     : base(manager, contact)
 {
 }