/// <summary>
        /// This method Notify Index Page
        /// </summary>
        public async void NotifyIndexPage()
        {
            try
            {
                // if the value for HasLoginResponse is true
                if (HasLoginResponse)
                {
                    // set the Artist
                    artist = LoginResponse.Artist;

                    // Notify the caller of the Login
                    await OnLogin.InvokeAsync(loginResponse);
                }
            }
            catch (Exception error)
            {
                // For debugging only
                DebugHelper.WriteDebugError("NotifyIndexPage", "Login", error);
            }
        }
Example #2
0
        /// <summary>
        /// Sends the login request to the repository and displays any login errors.
        /// </summary>
        /// <returns></returns>
        public async Task ExecuteLogin()
        {
            isPosting = true;

            Errors = new List <string>();

            ShowAuthError = false;
            _userForAuthentication.GrantType = "password";
            var result = await AuthenticationService.Login(_userForAuthentication);

            if (!result.Succeeded)
            {
                //Handles the event of a non sucessfull post to the api
                foreach (var error in result.Errors)
                {
                    Errors.Add(error.Value[0]);
                }

                isPosting = false;

                ShowAuthError = true;
            }
            else
            {
                var query = new Uri(NavigationManager.Uri).Query;
                await OnLogin.InvokeAsync(true);

                isPosting = false;

                if (QueryHelpers.ParseQuery(query).TryGetValue("returnUrl", out var value))
                {
                    NavigationManager.NavigateTo(value);
                }
                else
                {
                    NavigationManager.NavigateTo("/");
                }
            }
        }
        /// <summary>
        /// This method Receives Data from a child or parent component
        /// </summary>
        public async void ReceiveData(Message message)
        {
            // If the message object exists
            if (NullHelper.Exists(message))
            {
                // if a NewArtist signed up
                if (message.Text == "New Artist Signed Up")
                {
                    // if the parameters collection exists
                    if (message.HasParameters)
                    {
                        // iterate the parameters
                        foreach (NamedParameter parameter in message.Parameters)
                        {
                            // if this is the name
                            if (parameter.Name == "New Artist")
                            {
                                // get the current Artist
                                artist = parameter.Value as Artist;

                                // Create a LoginResponse object
                                LoginResponse loginResponse = new LoginResponse();

                                // Set to true
                                loginResponse.Success = true;

                                // set the Artist
                                loginResponse.Artist = artist;

                                // Notify the caller of the Login
                                await OnLogin.InvokeAsync(loginResponse);
                            }
                        }
                    }
                }
            }
        }