Exemplo n.º 1
0
        public IActionResult ParseUrl(ParseURLForm form)
        {
            ObjectResult output = StatusCode(500, error.ParseUrl);

            if (authProvider.IsLoggedIn)
            {
                User currentUser = authProvider.GetCurrentUser();

                if (form.IsSupportedWebsite())
                {
                    Recipe newRecipe = form.Parse();
                    newRecipe.UserWhoAdded = currentUser;
                    newRecipe = recipeDAL.AddRecipe(newRecipe);

                    if (newRecipe != null)
                    {
                        output = StatusCode(200, newRecipe);
                    }
                }
                else
                {
                    WebsiteRequest wr = form.GenerateWebsiteRequest();
                    wr.User = currentUser;
                    websiteRequestDAL.AddNewWebsiteRequest(wr);

                    emailProvider.NewWebsiteRequest(wr);


                    output = StatusCode(501, wr);
                }
            }
            else
            {
                output = StatusCode(401, error.NotLoggedIn);
            }

            return(output);
        }
Exemplo n.º 2
0
        public IActionResult ParseUrl(ParseURLForm form)
        {
            if (authProvider.IsLoggedIn)
            {
                User currentUser = authProvider.GetCurrentUser();

                if (form.IsSupportedWebsite())
                {
                    Recipe newRecipe = form.Parse();
                    newRecipe.UserWhoAdded = currentUser;
                    newRecipe = recipeDAL.AddRecipe(newRecipe);

                    if (newRecipe != null)
                    {
                        return(RedirectToAction("Recipe", new { id = newRecipe.ID }));
                    }
                    else
                    {
                        return(View("Error"));
                    }
                }
                else
                {
                    WebsiteRequest wr = form.GenerateWebsiteRequest();
                    wr.User = currentUser;
                    websiteRequestDAL.AddNewWebsiteRequest(wr);

                    emailProvider.NewWebsiteRequest(wr);


                    return(View("WebsiteRequestAdded", wr));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }