public LoginViewModel()
 {
     this.IsRemembered = true;
     this.IsEnabled    = true;
     this.Email        = ActivityMaps.Utils.Settings.LastUsedEmail;
     this.internet     = new CheckConnectionInternet();
 }
        private async void getUser()
        {
            var txt = this.Usertxt;

            try
            {
                CheckConnectionInternet.checkConnectivity();
                query = await App.MobileService.GetTable <User>().Where(p => p.Nickname == txt).ToListAsync();

                if (query.Count == 0)
                {
                    await Application.Current.MainPage.DisplayAlert("Warning", "The user was not found ", "Ok");

                    return;
                }
                if (query[0].Nickname.Equals(user[0].Nickname))
                {
                    await Application.Current.MainPage.DisplayAlert("Warning", "You can't rating yourself", "Ok");

                    return;
                }

                this.UserNick = query[0].Nickname;
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error ", ex.Message, "Ok");
            }
        }
 private async void Statistics()
 {
     CheckConnectionInternet.checkConnectivity();
     MainViewModel.GetInstance().Statistics       = new StatisticsViewModel(user);
     MainViewModel.GetInstance().GlobalStatistics = new GlobalStatisticsViewModel(user);
     await Application.Current.MainPage.Navigation.PushAsync(new StatisticsPage());
 }
        public async void Assign(string user_Id_FK1)
        {
            this.IsRunning = true;
            CheckConnectionInternet.checkConnectivity();                                        //SelectedUser.User_Id_FK1
            var querry = await App.MobileService.GetTable <User>().Where(p => p.Id == user_Id_FK1).ToListAsync();

            MainViewModel.GetInstance().Profile = new ProfileViewModel(querry);
            await Application.Current.MainPage.Navigation.PushAsync(new ProfilePage());

            //SetValue(ref this.selectedActivity, null);
            //LoadActivity();

            /*
             * var action = await Application.Current.MainPage.DisplayAlert("Sure?", "Are you sure want to add " + SelectedUser.Nickname, "No", "Yes");
             * if (!action)//yess
             * {
             *
             *
             *
             *      int len = RandomId.length.Next(5, 10);
             *      Friend pending = new Friend
             *      {
             *              Id = RandomId.RandomString(len),
             *              User_Id_FK1 = user[0].Id,
             *              User_Friend_Id_FK2 = SelectedUser.Requested_By_FK1,
             *              Type = 1
             *      };
             *      int nl = RandomId.length.Next(5, 10);
             *      Friend friend = new Friend
             *      {
             *              Id = RandomId.RandomString(nl),
             *              User_Id_FK1 = SelectedUser.Requested_By_FK1,
             *              User_Friend_Id_FK2 = user[0].Id,
             *              Type = 1
             *      };
             *      try
             *      {
             *              await App.MobileService.GetTable<Friend>().InsertAsync(pending);
             *              await App.MobileService.GetTable<Friend>().InsertAsync(friend);
             *              await App.MobileService.GetTable<Pending_Friend>().DeleteAsync(SelectedUser);
             *              await Application.Current.MainPage.DisplayAlert("Succesfuly!", "DONE!", "ok");
             *              LoadFriends();
             *
             *      }
             *      catch (Exception ex)
             *      {
             *              await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
             *      }
             *
             *
             * }
             */

            this.IsRunning = false;



            // note name is property in my model (say : GeneralDataModel )
        }
 private async void Friends()
 {
     CheckConnectionInternet.checkConnectivity();
     MainViewModel.GetInstance().FriendList     = new FriendListViewModel(user);
     MainViewModel.GetInstance().PendingFriends = new PendingFriendsViewModel(user);
     MainViewModel.GetInstance().Friends        = new FriendsViewModel(user);
     await Application.Current.MainPage.Navigation.PushAsync(new FriendsPage());
 }
Example #6
0
        private async void CreateActivity()
        {
            CheckConnectionInternet.checkConnectivity();
            MainViewModel.GetInstance().CreateActivity = new CreateActivityViewModel(userQuery, userLog, Categories);
            await Application.Current.MainPage.Navigation.PushAsync(new CreateActivityPage());

            //LoadActivity();
        }
Example #7
0
        private async void Menu()
        {
            CheckConnectionInternet.checkConnectivity();
            MainViewModel.GetInstance().Menu = new MenuViewModel(userQuery, userLog);
            await Application.Current.MainPage.Navigation.PushAsync(new MenuPage());

            //LoadActivity();
        }
        public LoginViewModel(string email)
        {
            CheckConnectionInternet.checkConnectivity();
            this.IsRemembered = true;
            this.IsEnabled    = true;

            this.Email    = email;
            this.Email    = ActivityMaps.Utils.Settings.LastUsedEmail;
            this.internet = new CheckConnectionInternet();

            this.isRegistered = true;
        }
Example #9
0
        private async void TakePicture()
        {
            CheckConnectionInternet.checkConnectivity();
            await CrossMedia.Current.Initialize();

            var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);



            if (cameraStatus != PermissionStatus.Granted)
            {
                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera });

                cameraStatus = results[Permission.Camera];
            }

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "No camera avaible",
                    "Accept");

                return;
            }

            if (cameraStatus == PermissionStatus.Granted)
            {
                var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                {
                    DefaultCamera      = Plugin.Media.Abstractions.CameraDevice.Front,
                    CompressionQuality = 92,
                    SaveMetaData       = true,
                    Name = "test.jpg"
                });

                if (file == null)
                {
                    return;
                }
                source = file.Path;
                Image  = ImageSource.FromStream(() => file.GetStream());
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Permissions Denied", "Unable to take photos.", "OK");

                //On iOS you may want to send your user to the settings screen.
                //CrossPermissions.Current.OpenAppSettings();
            }
            this.isReady = true;
        }
        public async void Delete(string user_Id_FK1)
        {
            this.IsRunning = true;
            CheckConnectionInternet.checkConnectivity();



            try
            {
                var query = await App.MobileService.GetTable <Friend>().Where(p => p.User_Friend_Id_FK2 == user_Id_FK1 && p.User_Id_FK1 == user[0].Id).ToListAsync();

                var queryOther = await App.MobileService.GetTable <Friend>().Where(p => p.User_Id_FK1 == user_Id_FK1 && p.User_Friend_Id_FK2 == user[0].Id).ToListAsync();

                Friend delete = new Friend
                {
                    Id                 = query[0].Id,
                    User_Id_FK1        = query[0].User_Id_FK1,
                    User_Friend_Id_FK2 = query[0].User_Friend_Id_FK2,
                    Type               = query[0].Type
                };

                Friend deleteOther = new Friend
                {
                    Id                 = queryOther[0].Id,
                    User_Id_FK1        = queryOther[0].User_Id_FK1,
                    User_Friend_Id_FK2 = queryOther[0].User_Friend_Id_FK2,
                    Type               = queryOther[0].Type,
                };
                //await Application.Current.MainPage.DisplayAlert("Succesfuly!", queryOther[0].Nickname, "ok");
                //return;
                await App.MobileService.GetTable <Friend>().DeleteAsync(delete);      //me

                await App.MobileService.GetTable <Friend>().DeleteAsync(deleteOther); //other user

                await Application.Current.MainPage.DisplayAlert("Succesfuly!", "DONE!", "ok");

                LoadFriends();
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
            }



            this.IsRunning = false;



            // note name is property in my model (say : GeneralDataModel )
        }
Example #11
0
        private async void SelectPicture()
        {
            CheckConnectionInternet.checkConnectivity();
            var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage);

            if (storageStatus != PermissionStatus.Granted)
            {
                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Storage });

                storageStatus = results[Permission.Storage];
            }


            if (!CrossMedia.Current.IsPickPhotoSupported)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Picking a photo is not supported",
                    "Accept");

                return;
            }


            if (storageStatus == PermissionStatus.Granted)
            {
                var file = await CrossMedia.Current.PickPhotoAsync();

                if (file == null)
                {
                    return;
                }
                source = file.Path;

                Image = ImageSource.FromStream(() => file.GetStream());
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Permissions Denied", "Unable to choose photo.", "OK");
            }

            this.isReady = true;
        }
        private async void SignOut()
        {
            CheckConnectionInternet.checkConnectivity();

            await Application.Current.MainPage.Navigation.PushAsync(new LoginPage());
        }
 private async void Feedback()
 {
     CheckConnectionInternet.checkConnectivity();
     MainViewModel.GetInstance().Feedback = new FeedbackViewModel(user);
     await Application.Current.MainPage.Navigation.PushAsync(new FeedbackPage());
 }
Example #14
0
        private async void CreateActivity()
        {
            CheckConnectionInternet.checkConnectivity();

            //if ((this.StartDay.Date + this.StartHour) < DateTime.Now)
            //{
            //    await Application.Current.MainPage.DisplayAlert(
            //        "Message",
            //        "Past date is not allowed.",
            //        "Ok");
            //    return;
            //}

            //if (this.StartDay.Date + this.StartHour > this.FinishDay.Date + this.FinishHour)
            //{
            //    await Application.Current.MainPage.DisplayAlert(
            //        "Message",
            //        "The Start Date is greater than Finish Date",
            //        "Ok");
            //    this.FinishDay = this.StartDay;
            //    this.FinishHour = this.StartHour;
            //    return;

            //}
            ValidateDatetime();

            if (string.IsNullOrEmpty(this.ActivityName))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Activity Name.",
                    "Accept");

                return;
            }
            if (string.IsNullOrEmpty(this.Description))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter a description.",
                    "Accept");

                return;
            }
            if (SelectedCategory == null)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must select a Category.",
                    "Accept");

                return;
            }


            if (loc == null)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must select a Location.",
                    "Accept");

                return;
            }

            if ((this.StartDay.Date + this.StartHour) < DateTime.Now)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Message",
                    "Past date is not allowed.",
                    "Ok");

                this.StartHour = DateTime.Now.TimeOfDay;
                return;
            }


            string[] addrSplit = this.Placename.Split(',');
            for (int i = 0; i < addrSplit.Length; i++)
            {
                addrSplit[i] = addrSplit[i].Trim();
            }
            int len = RandomId.length.Next(5, 10);
            Activity_Location activity_location = new Activity_Location()
            {
                Id        = RandomId.RandomString(len),
                Nameplace = addrSplit[0],
                City      = addrSplit.Length == 5 ? addrSplit[2] : addrSplit[1],
                State     = "PR",//Cambiarlo luego con IF dinamico
                Country   = addrSplit.Length == 5 ? addrSplit[4] : addrSplit[3],
                ZipCode   = addrSplit.Length == 5 ? addrSplit[3] : addrSplit[2],
                IsSecure  = false,
                Latitude  = (decimal)this.loc.Latitude,
                Longitude = (decimal)this.loc.Longitude,
                CreatorOriginalPinLatitude  = (decimal)this.origLoc.Latitude,
                CreatorOriginalPinLongitude = (decimal)this.origLoc.Longitude
            };

            try
            {
                //find duplicate
                var query = await App.MobileService.GetTable <Activity_Location>().Where(
                    p => p.Nameplace == activity_location.Nameplace &&
                    p.City == activity_location.City &&
                    p.ZipCode == activity_location.ZipCode
                    ).ToListAsync();

                if (query.Count == 0)
                {
                    await App.MobileService.GetTable <Activity_Location>().InsertAsync(activity_location);
                }
                else
                {
                    var location = query?.FirstOrDefault();
                    activity_location.Id = location.Id;
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
            }

            Activity activity = new Activity()
            {
                Id                 = RandomId.RandomString(len),
                Name               = this.ActivityName,
                Created_Date       = DateTime.Now,
                IsPrivate          = false,//todo
                Start_Act_Datetime = this.StartDay.Date + this.StartHour,
                End_Act_Datetime   = this.FinishDay.Date + this.FinishHour,
                Description        = this.Description.TrimEnd().TrimStart(),
                Status             = 1,//check
                IsService          = this.IsService,
                Activity_Cat_Code  = SelectedCategory.Id,
                Activity_Loc_Id    = activity_location.Id
            };

            //ctivity history
            Activity_History activityHistory = new Activity_History()
            {
                Id = RandomId.RandomString(len),
                Activity_Code_Id   = activity.Id,
                Name               = this.ActivityName,
                Created_Date       = DateTime.Now,
                IsPrivate          = false,//todo
                Start_Act_Date     = this.StartDay.Date + this.StartHour,
                End_Act_Date       = this.FinishDay.Date + this.FinishHour,
                Description        = this.Description,
                Status             = 1,//check
                IsService          = this.IsService,
                Activity_Cat_code  = SelectedCategory.Id,
                Activity_Loc_Id_FK = activity_location.Id
            };

            userCreating = User_LogType.userLogTypesAsync(userQuery[0].Id, usLog);
            User_Entered entry = new User_Entered()
            {
                Id                = RandomId.RandomString(len),
                Status            = "in",
                IsCreator         = true,
                User_Log_Id_FK1   = userCreating.Id,
                Activity_Code_FK2 = activityHistory.Activity_Code_Id
            };
            Entered_History entryHistory = new Entered_History()
            {
                Id                = entry.Id,
                Status            = "in",
                IsCreator         = true,
                Activity_Code_FK2 = activityHistory.Activity_Code_Id,
                UserJoin          = userQuery[0].Id,
                UserCreator       = userQuery[0].Id
            };

            try
            {
                await App.MobileService.GetTable <Activity>().InsertAsync(activity);

                await App.MobileService.GetTable <Activity_History>().InsertAsync(activityHistory);

                await App.MobileService.GetTable <User_Log>().InsertAsync(userCreating);

                await App.MobileService.GetTable <User_Entered>().InsertAsync(entry);

                await App.MobileService.GetTable <Entered_History>().InsertAsync(entryHistory);
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
            }

            MainViewModel.GetInstance().Activity_Child = new ActivityViewModel(userQuery, entry);
            await Application.Current.MainPage.Navigation.PushAsync(new ActivityPage());
        }
 private async void Profile()
 {
     CheckConnectionInternet.checkConnectivity();
     MainViewModel.GetInstance().Profile = new ProfileViewModel(user);
     await Application.Current.MainPage.Navigation.PushAsync(new ProfilePage());
 }
        private async void Next()
        {
            this.IsRunning = true;
            CheckConnectionInternet.checkConnectivity();

            if (string.IsNullOrEmpty(this.Name))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Name.",
                    "Accept");

                this.IsRunning = false;
                return;
            }

            if (string.IsNullOrEmpty(this.Last_Name))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Last Name.",
                    "Accept");

                this.IsRunning = false;
                return;
            }

            if (string.IsNullOrEmpty(this.Nickname))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Nickname.",
                    "Accept");

                this.IsRunning = false;
                return;
            }
            if (this.Nickname.Length < 4)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "The length of Nickname most be greather than 3 letters.",
                    "Accept");

                this.IsRunning = false;
                return;
            }

            var nick = await App.MobileService.GetTable <User>().Where(p => p.Nickname == this.Nickname).ToListAsync();

            if (nick.Count > 0)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "This nickname has been taken.",
                    "Try Another");

                this.IsRunning = false;
                return;
            }


            if (string.IsNullOrEmpty(this.Phone))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Phone.",
                    "Accept");

                this.IsRunning = false;
                return;
            }
            if (this.Phone.Length < 10)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter a Phone with 10 digits.",
                    "Accept");

                this.IsRunning = false;
                return;
            }

            if (string.IsNullOrEmpty(this.Address))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Address.",
                    "Accept");

                this.IsRunning = false;
                return;
            }

            if (string.IsNullOrEmpty(this.City))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an City.",
                    "Accept");

                return;
            }

            if (string.IsNullOrEmpty(this.State))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an State.",
                    "Accept");

                return;
            }

            if (string.IsNullOrEmpty(this.Zip_Code))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Zip Code.",
                    "Accept");

                this.IsRunning = false;
                return;
            }

            if (SelectedGender == null)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must select an Gender.",
                    "Accept");

                this.IsRunning = false;
                return;
            }


            if (SelectedCountry == null)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must select an Country.",
                    "Accept");

                this.IsRunning = false;
                return;
            }


            int len = RandomId.length.Next(5, 10);

            Address newAddress = new Address()
            {
                Id       = RandomId.RandomString(len),
                Phone    = this.Phone.TrimEnd(),
                Address1 = this.Address.TrimEnd(),
                Address2 = string.Empty,
                City     = this.City.TrimEnd(),
                State    = this.State.TrimEnd(),
                Country  = this.SelectedCountry.Name.TrimEnd(),
                Zipcode  = this.Zip_Code.TrimEnd()
            };

            User newUSer = new User()
            {
                Id            = RandomId.RandomString(len),
                Name          = this.Name.TrimEnd(),
                Last_Name     = this.Last_Name.TrimEnd(),
                Nickname      = this.Nickname.TrimEnd(),
                Gender        = this.SelectedGender.Name.Substring(0, 1),
                Birthdate     = this.Birthdate.Date,
                IsAdmin       = false,
                Locked        = false,
                Address_Id_FK = newAddress.Id
            };

            /*
             * try
             * {
             *
             *      await App.MobileService.GetTable<Address>().InsertAsync(newAddress);
             *      await Application.Current.MainPage.DisplayAlert("Exito", "El contacto fue insertado", "Ok");
             *      await Application.Current.MainPage.Navigation.PushAsync(new EndRegisterPage());
             * }
             * catch (Exception ex)
             * {
             *      await Application.Current.MainPage.DisplayAlert("Error ", ex.Message, "Ok");
             * }
             */

            //new EndRegisterViewModel(newAddress);
            //MainViewModel.GetInstance().EndRegister = new EndRegisterViewModel();
            //await Application.Current.MainPage.Navigation.PushAsync(new EndRegisterPage(newAddress, newUSer));

            MainViewModel.GetInstance().EndRegister = new EndRegisterViewModel(newAddress, newUSer);
            await Application.Current.MainPage.Navigation.PushAsync(new EndRegisterPage());

            this.IsRunning = false;
        }
 private async void History()
 {
     CheckConnectionInternet.checkConnectivity();
     MainViewModel.GetInstance().History = new HistoryViewModel(user);
     await Application.Current.MainPage.Navigation.PushAsync(new HistoryPage());
 }
 private async void About()
 {
     CheckConnectionInternet.checkConnectivity();
     MainViewModel.GetInstance().About = new AboutViewModel();
     await Application.Current.MainPage.Navigation.PushAsync(new AboutPage());
 }
Example #19
0
        private async void NextActivityPage()
        {
            CheckConnectionInternet.checkConnectivity();


            if (string.IsNullOrEmpty(this.Email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Email.",
                    "Accept");

                return;
            }
            if (!IsValid(this.Email))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter a real Email.",
                    "Accept");

                return;
            }

            var checkEmail = await App.MobileService.GetTable <User>().Where(p => p.Email == this.Email).ToListAsync();

            if (checkEmail.Count > 0)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "This email has been registered.",
                    "Try Another");

                return;
            }

            if (string.IsNullOrEmpty(this.Password))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Password.",
                    "Accept");

                return;
            }

            if (this.Password.Length < 7)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Your Password length must be greather than 6.",
                    "Accept");

                return;
            }

            if (string.IsNullOrEmpty(this.ReEnterPassword))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Password.",
                    "Accept");

                return;
            }

            if (!(Password.Equals(ReEnterPassword)))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "Passwords not match.",
                    "Accept");

                return;
            }
            if (!this.isReady)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must take a picture or select one",
                    "Accept");

                return;
            }

            this.IsRunning = true;

            CurrentUser.Email        = Email;
            CurrentUser.IsActive     = true;
            CurrentUser.Created_Date = DateTime.Now;


            byte[] encryted = System.Text.Encoding.Unicode.GetBytes(Password);
            var    result   = System.Convert.ToBase64String(encryted);
            int    len      = RandomId.length.Next(5, 10);

            User_Password password = new User_Password
            {
                Id         = RandomId.RandomString(len),
                Password   = result,
                User_Id_FK = CurrentUser.Id
            };

            byteData         = AzureStorage.Convert.ToByteArray(source);
            uploadedFilename = await AzureStorage.AzureStorage.UploadFileAsync(AzureStorage.ContainerType.Image, new MemoryStream(byteData));

            string[] arr = source.Split('/');

            File_Path filepath = new File_Path
            {
                Id         = RandomId.RandomString(len),
                Type       = "Image",
                Path       = uploadedFilename,
                Filename   = arr[arr.Length - 1],
                FileUrl    = source,
                Saved_Date = DateTime.Today,
                User_Id_FK = CurrentUser.Id
            };

            try
            {
                await App.MobileService.GetTable <Address>().InsertAsync(CurrentAddress);
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
            }

            try
            {
                await App.MobileService.GetTable <User>().InsertAsync(CurrentUser);
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
            }

            try
            {
                await App.MobileService.GetTable <User_Password>().InsertAsync(password);
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
            }
            try
            {
                await App.MobileService.GetTable <File_Path>().InsertAsync(filepath);
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
            }

            /*
             * //logic azure upload blob
             * string storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=lioncode;AccountKey=oY4jZN5nSf4g/4ATkgHIPAgjVRxF3fYS/R1BfhT1k9Li98e7vEYq4/DY4y38LHQ9zjvsvIXI8qEDYQWeeHbxHQ==;EndpointSuffix=core.windows.net";
             * CloudStorageAccount account = CloudStorageAccount.Parse(storageConnectionString);
             * CloudBlobClient blobClient = account.CreateCloudBlobClient();
             * CloudBlobContainer blobContainer = blobClient.GetContainerReference("activitymaps");
             * blobContainer.CreateIfNotExists();
             * string sourcePath = this.source;
             * CloudBlockBlob destBlob = blobContainer.GetBlockBlobReference("activitymaps");
             *
             * // Setup the number of the concurrent operations
             * TransferManager.Configurations.ParallelOperations = 64;
             * // Setup the transfer context and track the upload progress
             * SingleTransferContext context = new SingleTransferContext();
             * // Upload a local blob
             * var task = TransferManager.UploadAsync(
             *      sourcePath, destBlob, null, context, CancellationToken.None);
             * task.Wait();
             */



            this.IsRunning = false;

            MainViewModel.GetInstance().Login = new LoginViewModel(CurrentUser.Email);
            await Application.Current.MainPage.Navigation.PushAsync(new LoginPage());
        }
 private async void Setting()
 {
     CheckConnectionInternet.checkConnectivity();
     MainViewModel.GetInstance().Setting = new SettingViewModel(user);
     await Application.Current.MainPage.Navigation.PushAsync(new SettingPage());
 }
        private async void Next()
        {
            this.IsFeedbackRunning = true;
            this.IsFeedbackEnable  = false;
            CheckConnectionInternet.checkConnectivity();

            if (string.IsNullOrEmpty(this.FeedbackDescription))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter a Description.",
                    "Accept");

                this.IsFeedbackRunning = false;
                this.IsFeedbackEnable  = true;
                return;
            }


            if (SelectedFeedbcakRating == null)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must select a Rating.",
                    "Accept");

                this.IsFeedbackRunning = false;
                this.IsFeedbackEnable  = true;
                return;
            }


            int len = RandomId.length.Next(5, 10);

            Feedback feedback = new Feedback()
            {
                Id         = RandomId.RandomString(len),
                Comment    = this.FeedbackDescription.TrimEnd(),
                Rating     = this.SelectedFeedbcakRating.FeedbackName,
                User_Id_FK = user[0].Id
            };

            try
            {
                await App.MobileService.GetTable <Feedback>().InsertAsync(feedback);

                await Application.Current.MainPage.DisplayAlert("Exito", "Done!", "Ok");

                this.IsFeedbackVisible = true;


                //MainViewModel.GetInstance().Feedback = new FeedbackViewModel(user);
                //await Application.Current.MainPage.Navigation.PushAsync(new FeedbackPage());
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error ", ex.Message, "Ok");
            }

            this.IsFeedbackRunning = false;
        }
Example #22
0
        private async void Location()
        {
            CheckConnectionInternet.checkConnectivity();
            if (string.IsNullOrEmpty(this.ActivityName))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter an Activity Name.",
                    "Accept");

                return;
            }
            if (string.IsNullOrEmpty(this.Description))
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must enter a description.",
                    "Accept");

                return;
            }
            if (SelectedCategory == null)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    "You must select a Category.",
                    "Accept");

                return;
            }

            //Permiso para usar el Mapa y GPS
            var LocationStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);

            if (LocationStatus != PermissionStatus.Granted)
            {
                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Location });

                LocationStatus = results[Permission.Location];
            }

            if (LocationStatus != PermissionStatus.Granted)
            {
                await Application.Current.MainPage.DisplayAlert("Permissions Denied", "Unable to choose Location.", "OK");
            }



            Activity act = new Activity()
            {
                Name = this.ActivityName,
                Start_Act_Datetime = this.StartDay + this.StartHour,
                End_Act_Datetime   = this.FinishDay + this.FinishHour,
                Description        = this.Description,
                IsService          = this.IsService,
                Activity_Cat_Code  = SelectedCategory.Id
            };

            MainViewModel.GetInstance().Location = new LocationViewModel(userQuery, userLog, categories, act, this.PickerCatIndex);
            await Application.Current.MainPage.Navigation.PushAsync(new LocationPage());
        }