Пример #1
0
 public async void openNewRecipe()
 {
     selectedRecipeID = "-1";
     es    = generateNewEditorState();
     Model = RecipeHelper.initializeBlankRecipe();
     refresh();
 }
Пример #2
0
 public async void refreshRecipe(string selectedRecipe)
 {
     //state = await getSessionID();
     selectedRecipeID = selectedRecipe;
     setRecipeIDQueryString(selectedRecipe);
     Model = RecipeHelper.GetRecipeDetails(selectedRecipe, state);
     StateHasChanged();
 }
Пример #3
0
        public async void refreshAndLogout()
        {
            //state = await getSessionID();
            RecipeHelper.Logout(state);
            state            = null;
            selectedRecipeID = "";
            //setRecipeIDQueryString("");
            await ProtectedSessionStore.DeleteAsync("session");

            Model = null;
            StateHasChanged();
        }
Пример #4
0
        public void CreateAccount()
        {
            ErrorMessage = "";
            if (password == confirmPassword)
            {
                string creationResponse = RecipeHelper.CreateAccount(username, email, password);

                var creationResponseMessage = SimpleJson.SimpleJson.DeserializeObject(creationResponse);

                if (creationResponseMessage.GetType() == typeof(string))
                {
                    string SessionState = RecipeHelper.Login(username, password);
                    isError = false;
                    setSessionID(SessionState);
                    userSettings.InvokeAsync(username);
                    refreshParent.InvokeAsync("");
                }
                else
                {
                    //its probably errors
                    IList <object> creationResponseObject = (IList <object>)creationResponseMessage;

                    if (creationResponseObject.Count() > 0)
                    {
                        isError = true;
                        foreach (var i in creationResponseObject)
                        {
                            IDictionary <string, object> creationResponseItem = (IDictionary <string, object>)i;
                            object error = "";
                            creationResponseItem.TryGetValue("Description", out error);
                            ErrorMessage += "" + error + " ";
                        }
                    }
                }
            }
            else
            {
                isError      = true;
                ErrorMessage = "Passwords do not match";
            }
        }
Пример #5
0
        public async void refresh()
        {
            var uri = NavManager.ToAbsoluteUri(NavManager.Uri);

            Microsoft.Extensions.Primitives.StringValues firstout = "";
            if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("RID", out firstout))
            {
                selectedRecipeID = firstout;
                if (Model.idString != selectedRecipeID)
                {
                    Model = RecipeHelper.GetRecipeDetails(selectedRecipeID, state);
                }
            }
            state = await getSessionID();

            if (RecipeHelper.isLoggedIn(state))
            {
                recipes = await RecipeHelper.GetRecipes(state);
            }
            StateHasChanged();
        }
Пример #6
0
        public async void Login()
        {
            string SessionState = RecipeHelper.Login(Username, Password);

            if (SessionState != "false")
            {
                isError = false;
                setSessionID(SessionState);
                string test = await getSessionID();

                string sesh = state;
            }
            else
            {
                isError = true;
            }
            ErrorMessage = "Login Failed";

            if (!isError)
            {
                userSettings.InvokeAsync(Username);
                refreshParent.InvokeAsync("");
            }
        }