Ejemplo n.º 1
0
        public App()
        {
            InitializeComponent();

            TechiechatService = DependencyService.Get <ITechiechatService>();

            var account = AccountStore.Create().FindAccountsForService("techiechat").FirstOrDefault();

            if (account != null)
            {
                MainPage = new NavigationPage(new MapChatPage());

                User = new Techie()
                {
                    Id          = account.Properties["Id"],
                    Username    = account.Username,
                    Email       = account.Properties["Email"],
                    ProfileIcon = account.Properties["ProfileIcon"]
                };



                return;
            }
            MainPage = new NavigationPage(new Techiechat.MainPage());
        }
Ejemplo n.º 2
0
        public async Task <Techie> CreateTechie(Techie techie)
        {
            techie.Id = ObjectId.GenerateNewId();
            await _techieDao.CreateTechie(techie);

            return(techie);
        }
Ejemplo n.º 3
0
        private void AppOnNewMessageReceveid(object sender, Techie techie)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                lock (Lock)
                {
                    MapControl.SelectedPin = null;

                    var p = techie.LastLocation;
                    var t = Users.FirstOrDefault(x => x.ID == techie.Id);

                    if (t == null)
                    {
                        t = new TKCustomMapPin()
                        {
                            ID    = techie.Id, Image = techie.ProfileIcon,
                            Title = techie.Username
                        };
                        Users.Add(t);
                    }

                    t.Position = new Position(p.Coordinates[0], p.Coordinates[1]);
                    t.Subtitle = techie.Email;

                    MapControl.SelectedPin = t;
                }
            });
        }
Ejemplo n.º 4
0
        public ViewTechieViewModel(Techie techie)
        {
            Name = techie.Name;

            var publicationBo = new PublicationBO();

            Task.Run(async() =>
            {
                var publications = await publicationBo.ListPublicationsPerTechieId(techie.Id);

                Points = publications.Sum(a => a.Likes.Count) - publications.Sum(a => a.Dislikes.Count);
                Posts  = publications.Count;
            }).Wait();
        }
Ejemplo n.º 5
0
        public async Task <bool> RegisterAsync(Techie user)
        {
            try
            {
                var coll = UriFactory.CreateDocumentCollectionUri(Database, Collection);

                await _client.UpsertDocumentAsync(coll, user);

                return(true);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(false);
            }
        }
Ejemplo n.º 6
0
        private async void StartChat(object sender, EventArgs e)
        {
            using (UserDialogs.Instance.Loading("Registering your account..."))
            {
                var id = await GetPushId();

                var location = await CrossGeolocator.Current.GetPositionAsync(TimeSpan.FromSeconds(5));

                //Send to the cloud
                var techie = new Techie()
                {
                    Id           = id,
                    Username     = UserName.Text,
                    Email        = Email.Text,
                    ProfileIcon  = ProfileIcon,
                    LastLocation = new Helpers.Point(location.Latitude, location.Longitude)
                };

                var resp = await App.TechiechatService.RegisterAsync(techie);

                if (!resp)
                {
                    UserDialogs.Instance.ShowError("Check if your info is correct and try again.");
                    return;
                }

                var account = new Account(UserName.Text);
                account.Properties.Add("Id", techie.Id);
                account.Properties.Add("Email", techie.Email);
                account.Properties.Add("ProfileIcon", techie.ProfileIcon);

                App.User = techie;

                await AccountStore.Create().SaveAsync(account, "techiechat");
            }

            await Navigation.PushAsync(new MapChatPage());
        }
Ejemplo n.º 7
0
 public TechiesViewModel(Techie techie)
 {
     Name = techie.Name;
 }