Exemple #1
0
        public async void Login()
        {
            try
            {
                // object resultString;
                if (App.User == null)
                {
                    App.User = await loginService.AuthenticateAsync();

                    LoggedIn = true;
                }
                else
                {
                    toastService.ShowToast($"User {App.User.UserName} is already authenticated", "User authenticated");
                }
                var authResult = await pushNotificationService.CreateInstallation();

                App.User.UserName = authResult.UserId;
                Username          = authResult.UserId;
                toastService.ShowToast($"User {Username} has authenticated successfully", "Success");
                Groups = authResult.SharedDevices;
                clipboardService.DataCopiedToClipboard += (s, data) =>
                {
                    SharedData = data;
                };

                pushNotificationService.NotificationReceived += async(s, e) =>
                {
                    e.Cancel = true;
                    XmlDocument xDoc       = e.ToastNotification.Content;
                    string      copiedText = xDoc.InnerText;
                    App.IncomingCopiedText = copiedText;



                    await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                                                     async() =>
                    {
                        bool result = await clipboardService.IsTextSameWithClipboard(copiedText);
                        if (!result)
                        {
                            DataPackage clipboardContent = new DataPackage();
                            clipboardContent.SetText(copiedText);

                            Clipboard.SetContent(clipboardContent);
                        }
                    });
                };
                GetHistoryData();
            }

            catch (Exception e)
            {
                toastService.ShowToast($"Error occured while authenticating user: {e.Message}", "Authentication failed");
            }
        }
Exemple #2
0
        public async Task UnpublishProject()
        {
            project.IsPublished = false;
            await ProjectData.UpdatePublishStatus(project);

            ToastService.ShowToast(ToastLevel.Success, "Done", "-");
        }
        private async void RegisterUser()
        {
            ErrorVisibility = Visibility.Collapsed;

            if (string.IsNullOrEmpty(User.Firstname))
            {
                ErrorText       = "Voornaam is niet ingevuld!";
                ErrorVisibility = Visibility.Visible;
                return;
            }

            if (string.IsNullOrEmpty(User.Lastname))
            {
                ErrorText       = "Achternaam is niet ingevuld!";
                ErrorVisibility = Visibility.Visible;
                return;
            }

            if (string.IsNullOrEmpty(User.Email))
            {
                ErrorText       = "Email is niet ingevuld!";
                ErrorVisibility = Visibility.Visible;
                return;
            }
            if (string.IsNullOrEmpty(User.Password) || string.IsNullOrEmpty(PasswordRepeat))
            {
                ErrorText       = "Wachtwoord is niet ingevuld!";
                ErrorVisibility = Visibility.Visible;
                return;
            }
            if (!PasswordRepeat.Equals(User.Password))
            {
                ErrorText       = "Wachtwoorden komen niet overeen!";
                ErrorVisibility = Visibility.Visible;
                return;
            }
            IsEnabled = false;
            try
            {
                await UserViewModel.Register(User);

                if (UserViewModel.IsLoggedIn)
                {
                    User      = UserViewModel.User;
                    IsEnabled = true;
                    NavigationService.Navigate(typeof(OverviewViewModel).FullName);
                }
                else
                {
                    ErrorText       = "Email reeds in gebruik!";
                    ErrorVisibility = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                toastService.ShowToast("Registreren mislukt!", ex.Message);
            }
            IsEnabled = true;
        }
        private async void OnDeleteClick()
        {
            if (Selected != null)
            {
                IsEnabled = true;
                try
                {
                    ContentDialog dialog = new ContentDialog();
                    dialog.Title = $"Bent u zeker dat u {Selected.Name} wilt verwijderen?";
                    dialog.IsSecondaryButtonEnabled = true;
                    dialog.PrimaryButtonText        = "Ja";
                    dialog.SecondaryButtonText      = "Nee";
                    var result = await dialog.ShowAsync();

                    if (result == ContentDialogResult.Primary)
                    {
                        Debug.WriteLine(Selected.Id);
                        var success = await promotionService.DeletePromotion(Selected.Id);

                        if (success)
                        {
                            toastService.ShowToast("Onderneming verwijderd", "");

                            Source.Clear();
                            var items = await promotionService.GetPromosOfOwner();

                            items.ForEach(item => { Source.Add(item); });
                            if (Source.Count > 0)
                            {
                                Selected = Source.First();
                            }
                        }
                        else
                        {
                            toastService.ShowToast("Promotie niet verwijderd", "Probeer later opnieuw");
                        }
                    }
                }
                catch (Exception)
                {
                    toastService.ShowToast("Er ging iets mis", "Probeer later opnieuw");
                }
                IsEnabled = true;
            }
        }
        private void toggleNotificaciones_Toggled(object sender, RoutedEventArgs e)
        {
            SettingsService.Instance.MostrarNotificaciones = toggleNotificaciones.IsOn;

            if (toggleNotificaciones.IsOn)
            {
                ToastService.ShowToast("Nasa API", "Imagen del dia");
            }
        }
Exemple #6
0
        private async Task Export()
        {
            await Task.CompletedTask;

            ToastService.ShowToast("Export Currently Disabled", ToastLevel.Error);

            //var fileBytes = await WorkLogsService.GetDataForExport(WorkLogs);
            //await JsInterop.SaveAs($"Work Logs {DateTime.Now.ToLongDateString()}.xlsx", fileBytes);
        }
        protected void Divide()
        {
            if (Operand2 == 0)
            {
                ToastService.ShowToast("Cannot divide by zero.");
                return;
            }

            Result = Operand1 / Operand2;
        }
Exemple #8
0
        private void MemoryManager_AppMemoryUsageIncreased(object sender, object e)
        {
            ToastService.ShowToast("Nasa API", "Memory usage increased");

            var level = MemoryManager.AppMemoryUsageLevel;

            if (level == AppMemoryUsageLevel.OverLimit || level == AppMemoryUsageLevel.High)
            {
                ReduceMemoryUsage(MemoryManager.AppMemoryUsageLimit);
            }
        }
Exemple #9
0
        private void MemoryManager_AppMemoryUsageLimitChanging(object sender, AppMemoryUsageLimitChangingEventArgs e)
        {
            ToastService.ShowToast("Nasa API", "Memory usage limit changing from "
                                   + (e.OldLimit / 1024) + "K to "
                                   + (e.NewLimit / 1024) + "K");

            if (MemoryManager.AppMemoryUsage >= e.NewLimit)
            {
                ReduceMemoryUsage(e.NewLimit);
            }
        }
Exemple #10
0
        private void ReduceMemoryUsage(ulong appMemoryUsageLimit)
        {
            if (isInBackgroundMode && Window.Current.Content != null)
            {
                ToastService.ShowToast("Nasa API", "Unloading view");

                Window.Current.Content = null;
            }

            GC.Collect();
        }
Exemple #11
0
        public async void ConfirmDialog_OnDialogClose()
        {
            await StoreDataService.DeleteStore(this.SelectedStore.Id);

            Stores = (await StoreDataService.GetAllStores()).ToList();
            ToastService.ShowToast($"Store ''{this.SelectedStore.Name}'' has been deleted!", ToastLevel.Warning);
            //DisplayStatusAlert("alert-danger", $"Store ''{this.SelectedStore.Name}'' has been deleted!");

            await FilterStores();
            await ScrollToTop();
        }
Exemple #12
0
    public async Task <T> HttpPost <T>(string uri, object dataToSend)
        where T : class
    {
        var content = ToJson(dataToSend);

        var result = await _httpClient.PostAsync($"{_apiUrl}{uri}", content);

        if (!result.IsSuccessStatusCode)
        {
            var exception = JsonSerializer.Deserialize <ErrorDetails>(await result.Content.ReadAsStringAsync(), new JsonSerializerOptions
            {
                PropertyNameCaseInsensitive = true
            });
            _toastService.ShowToast($"Error : {exception.Message}", ToastLevel.Error);

            return(null);
        }

        return(await FromHttpResponseMessage <T>(result));
    }
        public void ShowToast(ToastLevel level)
        {
            var toast = ToastService.ShowToast(level);

            BackgroundCssClass = toast.Item1;
            IconCssClass       = toast.Item2;
            Heading            = toast.Item3;
            isWarning          = Heading == ToastLevel.Warning.ToString();
            IsVisible          = true;
            windowShow         = "show";
        }
Exemple #14
0
        private async Task FixDevOpsIds()
        {
            if (ProcessingDevOpsFix)
            {
                return;
            }
            ProcessingDevOpsFix = true;
            var message = await WorkLogsService.FixDevOpsIds();

            ToastService.ShowToast(message, ToastLevel.Info);
            ProcessingDevOpsFix = false;
        }
Exemple #15
0
        private void ShowCustomToast()
        {
            var customView = new UIView(new CGRect(0, 0, 80, 400));

            customView.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin |
                                          UIViewAutoresizing.FlexibleRightMargin |
                                          UIViewAutoresizing.FlexibleTopMargin |
                                          UIViewAutoresizing.FlexibleBottomMargin;
            customView.BackgroundColor = UIColor.Orange;

            ToastService.ShowToast(View, customView, ToastPosition.Top, 5f, () => Debug.WriteLine("toast finished"));
        }
Exemple #16
0
        public async Task <Post> CreatePostAsync(string title, string text)
        {
            var createdPost = await _api.CreatePostAsync(title, text, CurrentCategory.Id);

            if (createdPost != null)
            {
                _toastService.ShowToast("The post was created!", ToastLevel.Success);
            }

            return(createdPost);
        }
Exemple #17
0
        async Task CreateTodo()
        {
            var result = await Client.PostAsJsonAsync("api/v1.0/todo", todo);

            if (result.IsSuccessStatusCode)
            {
                ToastService.ShowToast("Saved successfully", ToastLevel.Success);
            }
            else
            {
                ToastService.ShowToast("Failed to save", ToastLevel.Error);
            }
            Nav.NavigateTo("todo");
        }
 internal void ProcessNotifications(object sender, StackArgs e)
 {
     e.Notifications?.ForEach(notification =>
     {
         string key = GetNotificationKey(notification);
         if (!_KnownNotifications.ContainsKey(key))
         {
             _KnownNotifications.Add(key, notification);
             toastService.ShowToast(notification);
             // this can be optimized so that this is only called once but it doesn't matter for right now
             OnPropertyChanged("Notifications");
         }
     });
 }
Exemple #19
0
        private void App_LeavingBackground(object sender, LeavingBackgroundEventArgs e)
        {
            ToastService.ShowToast("Nasa API", "Leaving background");

            isInBackgroundMode = false;

            if (Window.Current.Content == null)
            {
                ToastService.ShowToast("Nasa API", "Loading view");

                // Create root frame
                CreateRootFrame(ApplicationExecutionState.Running, string.Empty);
            }
        }
Exemple #20
0
        public async Task LoadDataAsync(MasterDetailsViewState viewState)
        {
            try
            {
                Source.Clear();

                _entlist = await entService.GetEnterprisesByOwner();

                _entlist.ForEach(ent => { Source.Add(ent); });


                if (viewState == MasterDetailsViewState.Both)
                {
                    if (Source.Count > 0)
                    {
                        Selected = Source.First();
                    }
                }
            } catch (Exception)
            {
                toastService.ShowToast("Er ging iets mis", "probeer later opnieuw");
            }
        }
Exemple #21
0
        private async Task StartImport()
        {
            await Task.CompletedTask;

            ToastService.ShowToast("Import Currently Disabled", ToastLevel.Error);
            Done();
            return;

            //var data = await JsInterop.GetFileData("fileUpload");

            //var message = await WorkLogsService.ImportFromExcel(data);
            //ToastService.ShowToast(message, ToastLevel.Info);

            //Done();
        }
Exemple #22
0
        public async void AddStoreDialog_OnDialogClose()
        {
            string message = string.Empty;

            if (this.SelectedStore != null)
            {
                message = $"Store ''{this.SelectedStore.Name}'' has been updated!";
            }
            else
            {
                message = "A new Store has been created!";
            }
            ToastService.ShowToast(message, ToastLevel.Success);
            //DisplayStatusAlert("alert-success", message);
            await FilterStores();
        }
Exemple #23
0
        protected async Task RemoveCakeMark()
        {
            Error.ErrorMessage = null;

            var result = await this.CakeMarkService.RemoveCakeMark(CakeMarkBoard.CakeMarkGridData.LatestEventDate);

            if (!result.Success)
            {
                Error.ErrorMessage = result.GetStatusMessage(RemoveCakeMarkFailedMessage);
            }
            else
            {
                await ToastService.ShowToast(RemoveCakeMarkSuccessMessage);
            }

            await CakeMarkTally.Refresh();

            await CakeMarkBoard.Refresh();
        }
        private async void DeleteInternal(ModalResult modalResult)
        {
            if (!modalResult.Cancelled)
            {
                var isDeleted = await OrganizationsService.DeleteOrganization((int)modalResult.Data);

                if (isDeleted)
                {
                    StateHasChanged();
                    await Refresh();
                }
                else
                {
                    ToastService.ShowToast("Unable to delete! Projects exists on this Organization!", ToastLevel.Error);
                }
            }

            Modal.OnClose -= DeleteInternal;
        }
Exemple #25
0
        private async void DeleteInternal(ModalResult modalResult)
        {
            if (!modalResult.Cancelled)
            {
                var isDeleted = await EpicsService.DeleteEpic((int)modalResult.Data);

                if (isDeleted)
                {
                    await Refresh();

                    StateHasChanged();
                }
                else
                {
                    ToastService.ShowToast("Unable to delete! Work logs exists on this epic!", ToastLevel.Error);
                }
            }

            Modal.OnClose -= DeleteInternal;
        }
Exemple #26
0
        public async Task LogIn()
        {
            var result = await Client.GetAsync($"api/v1.0/user/{UserData.Email}");

            User data = await result.Content.ReadFromJsonAsync <User>();

            if (result.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                ToastService.ShowToast("User could not be found", ToastLevel.Error);
            }
            else
            {
                //string json = JsonConvert.SerializeObject(data);
                //await Storage.SetItemAsync<string>("loginData", json);

                //var userData = await Storage.GetItemAsStringAsync("loginData");
                //User user =  JsonConvert.DeserializeObject<User>(userData);

                Nav.NavigateTo("todo");
            }
        }
Exemple #27
0
        private async Task <ApiResponse> RequestAsync(string uri, string method, HttpContent content)
        {
            var request = new HttpRequestMessage()
            {
                Method     = new HttpMethod(method),
                RequestUri = new Uri(uri),
                Content    = content
            };

            // sets proper cors headers
            SetCorsHeaders(request);
            // get server response
            var response = await _httpClient.SendAsync(request);

            // string response body
            var responseBody = await response.Content.ReadAsStringAsync();

            // convert to ApiResponse object through newtonsoft, which will set the status and error properties
            var apiResp = JsonConvert.DeserializeObject <ApiResponse>(responseBody);

            // set the httpstatus code of the ApiResponse to the http response
            apiResp.StatusCode = response.StatusCode;
            apiResp.Content    = responseBody;

            Console.WriteLine(apiResp.StatusString);
            if (apiResp.StatusString == "error")
            {
                string errMessage;
                // get full error message mapping
                _errorStringMapping.TryGetValue(apiResp.ErrorString, out errMessage);
                if (errMessage == null)
                {
                    errMessage = apiResp.ErrorString;
                }

                _toastService.ShowToast(errMessage, ToastLevel.Error);
            }
            return(apiResp);
        }
        private async void LoginUser()
        {
            ErrorVisibility = Visibility.Collapsed;
            if (string.IsNullOrEmpty(User.Email))
            {
                ErrorText       = "Email is niet ingevuld!";
                ErrorVisibility = Visibility.Visible;
                return;
            }
            if (string.IsNullOrEmpty(User.Password))
            {
                ErrorText       = "Wachtwoord is niet ingevuld!";
                ErrorVisibility = Visibility.Visible;
                return;
            }
            IsEnabled = false;
            try
            {
                await UserViewModel.LogUserIn(User);

                if (UserViewModel.IsLoggedIn)
                {
                    User      = UserViewModel.User;
                    IsEnabled = true;
                    NavigationService.Navigate(typeof(OverviewViewModel).FullName);
                }
                else
                {
                    ErrorText       = "Wachtwoord en Email komen niet overeen!";
                    ErrorVisibility = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                toastService.ShowToast("Inloggen mislukt!", ex.Message);
            }
            IsEnabled = true;
        }
Exemple #29
0
        protected async Task AddConfirmedCakeMark()
        {
            Error.ErrorMessage = null;

            var result = await this.CakeMarkService.AddCakeMark(CakeMarkBoard.CakeMarkGridData.LatestEventDate);

            await JSRuntime.HideModal("addCakeMarkModal");

            if (!result.Success)
            {
                Error.ErrorMessage = result.GetStatusMessage(AddCakeMarkFailedMessage);
            }
            else
            {
                await ToastService.ShowToast(AddCakeMarkSuccessMessage);
            }

            await CakeMarkTally.Refresh();

            await SuperCakeMarkTally.Refresh();

            await CakeMarkBoard.Refresh();
        }
Exemple #30
0
        public async void Delete(CodeHubUser user)
        {
            ToastService.ShowToast("Deleting users is currently disabled!", ToastLevel.Warning);

            await Task.Yield();
        }