Пример #1
0
        private async Task UploadToBlob()
        {
            if (TitleEntry == null || TitleEntry.Trim() == "" || !PickerItemSelectedFlag)
            {
                await _pageService.DisplayAlert("Error!", "Please fill the form properly", "Ok", "Cancel");

                return;
            }

            Busy = true;

            var courseid   = _coursesList[_selectedCourseIndex].Id;
            var titleEntry = TitleEntry;

            await DependencyService.Get <IUploader>().UploadToBlob(courseid, titleEntry, Settings.StudentId, IsGeneralToggled);

            await _pageService.DisplayAlert("Upload Success", "Notebook Added Successfully.", "Ok", "Cancel");

            await _pageService.PushAsync(new Views.NotebooksDB.NotebooksMainPage());

            await FCMPushNotificationSender.Send(
                "NS" + courseid, "New Notebook", "New notebook that you may interest in has been added");

            Busy = false;
        }
Пример #2
0
        private async Task <Ride> PostRide()
        {
            Busy = true;

            var postUrl = "https://altaarefapp.azurewebsites.net/api/Rides";

            var content      = new StringContent(JsonConvert.SerializeObject(NewRide), Encoding.UTF8, "application/json");
            var response     = _client.PostAsync(postUrl, content);
            var InsertedRide = JsonConvert.DeserializeObject <Ride>(await response.Result.Content.ReadAsStringAsync());

            if (response.Result.IsSuccessStatusCode)
            {
                // Send Notification
                await FCMPushNotificationSender.Send(
                    "RP" + NewRide.FromCity.Trim() + NewRide.ToCity.Trim(), "New Ride", "New ride to " + NewRide.ToCity.Trim() + " has been added, check it out!");

                var datestring = NewRide.Date.ToString("MMdd");
                datestring += NewRide.Date.ToString("HHmm");

                Busy = false;

                return(InsertedRide);
            }
            else
            {
                await _pageService.DisplayAlert("Error", "Something went wrong while adding the ride", "OK", "Cancel");

                Busy = false;

                return(null);
            }
        }
        private async Task <int> PostHelpRequest()
        {
            Busy = true;

            var postUrl = "https://altaarefapp.azurewebsites.net/api/HelpRequests";

            var content  = new StringContent(JsonConvert.SerializeObject(newHelpRequest), Encoding.UTF8, "application/json");
            var response = _client.PostAsync(postUrl, content);

            var InsertedHelpRequestId = JsonConvert.DeserializeObject <Models.HelpRequest>(await response.Result.Content.ReadAsStringAsync());


            if (response.Result.IsSuccessStatusCode)
            {
                foreach (var faculty in FacultiesSelectedList)
                {
                    await FCMPushNotificationSender.Send(
                        "HR" + faculty.Id, "Help", "Someone asked for help in your faculty");
                }

                Busy = false;
                return(InsertedHelpRequestId.Id);
            }
            else
            {
                await _pageService.DisplayAlert("Error", "Something went wrong with adding Help Request", "OK", "Cancel");

                Busy = false;
                return(-1);
            }
        }
        private async Task HandleSubscribeButtonTap()
        {
            if (NewRide.FromCity != null && NewRide.ToCity != null)
            {
                // Subscribe to topic
                DependencyService.Get <IFCMNotificationSubscriber>().Subscribe("RP" + NewRide.FromCity.Trim() + NewRide.ToCity.Trim());

                // Register StudentId with the notification in the db, and update the list in App Properties
                var insertedUserNotification = await FCMPushNotificationSender.AddNotification(
                    new UserNotification
                {
                    StudentId = Settings.StudentId,
                    Topic     = "RP" + NewRide.FromCity.Trim() + NewRide.ToCity.Trim(),
                    Title     = "New Ride",
                    Body      = "Someone published new ride that you interested in"
                });
            }

            await _pageService.PushAsync(new Views.Hitchhicking.HitchhickingMainPage());
        }
Пример #5
0
        private async void OnSubmitButtonTapped()
        {
            if (!IsFormValid())
            {
                await _pageService.DisplayAlert("Error", "Please fill the form properly.", "OK", "Cancel");

                return;
            }

            var courseid = _coursesList[_selectedCourseIndex].Id;

            StudyGroup.CourseId  = courseid;
            StudyGroup.StudentId = Settings.StudentId;


            var postUrl = "https://altaarefapp.azurewebsites.net/api/StudyGroups";

            var content  = new StringContent(JsonConvert.SerializeObject(StudyGroup), Encoding.UTF8, "application/json");
            var response = _client.PostAsync(postUrl, content);

            var insertedRes = await response.Result.Content.ReadAsStringAsync();

            var StudyGroupInserted = JsonConvert.DeserializeObject <Models.StudyGroup>(insertedRes);


            if (response.Result.IsSuccessStatusCode)
            {
                await _pageService.DisplayAlert("Group Created", "The group created successfuly", "OK", "Cancel");

                await _pageService.PushAsync(new Views.StudyGroups.SelectStudentsToInvite(StudyGroupInserted.CourseId, StudyGroupInserted.Id));

                await FCMPushNotificationSender.Send(
                    "SG" + StudyGroup.CourseId,
                    "New Study Group",
                    "New study group added in a course you interested in, join now!");
            }
            else
            {
                await _pageService.DisplayAlert("Error", "Something went wrong", "OK", "Cancel");
            }
        }
Пример #6
0
        private async Task HandleNRAddButton()
        {
            // Subscribe to topic
            DependencyService.Get <IFCMNotificationSubscriber>().Subscribe("NS" + _courseId);

            // Register StudentId with the notification in the db, and update the list in App Properties
            var insertedUserNotification = await FCMPushNotificationSender.AddNotification(
                new UserNotification
            {
                StudentId = Settings.StudentId,
                Topic     = "NS" + _courseId,
                Title     = "New Notebook",
                Body      = "New notebook that you may interest in has been added"
            });

            // update the SG list in this page
            if (insertedUserNotification != null)
            {
                NotificationList.Add(insertedUserNotification);
            }
        }
Пример #7
0
        private async Task HandleHRFacultyAddButton()
        {
            // Subscribe to topic
            DependencyService.Get <IFCMNotificationSubscriber>().Subscribe("HR" + _courseId);

            // Register StudentId with the notification in the db, and update the list in App Properties
            var insertedUserNotification = await FCMPushNotificationSender.AddNotification(
                new UserNotification
            {
                StudentId = Settings.StudentId,
                Topic     = "HRF" + _courseId,
                Title     = "Help",
                Body      = "Someone asked for help in your faculty"
            });

            // update the SG list in this page
            if (insertedUserNotification != null)
            {
                NotificationList.Add(insertedUserNotification);
            }
        }
Пример #8
0
        private async Task HandleHRCourseAddButton()
        {
            // Subscribe to topic
            DependencyService.Get <IFCMNotificationSubscriber>().Subscribe("HR" + _courseId);

            // Register StudentId with the notification in the db, and update the list in App Properties
            var insertedUserNotification = await FCMPushNotificationSender.AddNotification(
                new UserNotification
            {
                StudentId = Settings.StudentId,
                Topic     = "HRC" + _courseId,
                Title     = "Help!",
                Body      = "Some need help in a course you attend in, you may give him a help hand"
            });

            // update the SG list in this page
            if (insertedUserNotification != null)
            {
                NotificationList.Add(insertedUserNotification);
            }
        }
Пример #9
0
        private async Task HandleSGAddButton()
        {
            // Subscribe to topic
            DependencyService.Get <IFCMNotificationSubscriber>().Subscribe("SG" + _courseId);

            // Register StudentId with the notification in the db, and update the list in App Properties
            var insertedUserNotification = await FCMPushNotificationSender.AddNotification(
                new UserNotification
            {
                StudentId = Settings.StudentId,
                Topic     = "SG" + _courseId,
                Title     = "New Study Group",
                Body      = "New study group added in a course you interested in, join now!"
            });

            // update the SG list in this page
            if (insertedUserNotification != null)
            {
                NotificationList.Add(insertedUserNotification);
            }
        }
Пример #10
0
        private async void OnSubmitButtonTapped(object obj)
        {
            if (NewHelpRequest.Message.Trim() != "")
            {
                // if request not general - show next page to pick Faculties
                if (!NewHelpRequest.IsGeneral)
                {
                    await _pageService.PushAsync(new Views.MutualHelp.SelectHelpRequestFaculties(NewHelpRequest));
                }
                else
                {
                    await PostGeneralHelpRequest();

                    await FCMPushNotificationSender.Send(
                        "HRGeneral", "Help", "Someone asked for help, check it out.");

                    await _pageService.PushAsync(new Views.CommonPages.MyHelpRequests());
                }
            }
            else
            {
                await _pageService.DisplayAlert("Invalid Entry", "Please fill all form correctly", "OK", "Cancel");
            }
        }