Ejemplo n.º 1
0
        public IActionResult ChangePassword(ChangePasswordViewModel cpvm)
        {
            ObjectResult output = authProvider.IsLoggedIn ? StatusCode(500, error.PasswordChange) : StatusCode(500, error.NotLoggedIn);

            if (ModelState.IsValid)
            {
                if (authProvider.ChangePassword(cpvm.OldPassword, cpvm.ConfirmPassword))
                {
                    output = StatusCode(200, authProvider.GetCurrentUser());
                }
            }
            else if (cpvm.NewPassword != cpvm.ConfirmPassword)
            {
                output = StatusCode(500, error.PasswordMismatch);
            }

            return(output);
        }
Ejemplo n.º 2
0
        public void Delete(int recipeId, string filename)
        {
            if (authProvider.IsLoggedIn)
            {
                if (imageDAL.DoesUserOwnImage(authProvider.GetCurrentUser()))
                {
                    filename = cloudStorage.DeleteFile(filename);

                    imageDAL.Remove(recipeId, filename);
                }
            }
        }
Ejemplo n.º 3
0
        public IActionResult MyRecipes()
        {
            ObjectResult output = StatusCode(500, error.MyRecipes);

            if (authProvider.IsLoggedIn)
            {
                List <Recipe> myRecipes = recipeDAL.GetMyRecipes(authProvider.GetCurrentUser().Id);

                if (myRecipes != null)
                {
                    output = StatusCode(200,
                                        new RecipeBookModel(recipeDAL.GetMyRecipes(authProvider.GetCurrentUser().Id))
                                        );
                }
            }
            else
            {
                output = StatusCode(401, error.NotLoggedIn);
            }

            return(output);
        }