You are on page 1of 6

Instruction for recipe world, views, controller, shared_layout.

Copy & paste all (yang highlight kuning tu yang aku add kalau ada part yg kau dah buat tambah yg
aku highlight je)

Controller

1. Controllers> HomeController.cs

using Microsoft.AspNetCore.Mvc;
using RecipeWorld.Models;
using System.Diagnostics;

namespace RecipeWorld.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;

public HomeController(ILogger<HomeController> logger)


{
_logger = logger;
}

public IActionResult Index()


{
return View();
}

public IActionResult Privacy()


{
return View();
}

public IActionResult PopularItems()


{
return View();
}

public IActionResult AboutUs()


{
return View();
}

public IActionResult Recipe()


{
return View();
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None,


NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ??
HttpContext.TraceIdentifier });
}
}
}
Views

2. Views> Home> add view> Razor view-empty (ikut nama action method yg highlight warna
hijau dkt atas buat satu-satu)

Lepastu bukak lepastu replace content dgn ni

AboutUs.cshtml
@{
ViewData["Title"] = "About Us";
}
<h1>@ViewData["Title"]</h1>

<p>

Recipe World is a dynamic recipe sharing website that was established in 2010
with a simple yet powerful mission: to connect food enthusiasts from around the
world
and inspire them to explore the vast and diverse world of recipes. Founded by
a team of passionate individuals with a deep appreciation for culinary arts,
Recipe World quickly became a go-to platform for home cooks, professional
chefs, and anyone seeking culinary inspiration.

From its humble beginnings, Recipe World has grown into a global community of
food lovers united by their shared love for cooking and exploration. With a vast
collection of meticulously curated recipes, spanning traditional classics to
innovative creations, Recipe World offers an extensive culinary library to
satisfy every taste and dietary preference.

Recipe World takes pride in fostering an environment of creativity,


collaboration, and cultural exchange. The platform encourages users to not only
share their favorite recipes but also to tell the stories behind them, creating a
tapestry of flavors and traditions from all corners of the globe. The company
believes that food has the power to transcend boundaries, bridge cultures, and
ignite conversations, and Recipe World serves as a virtual meeting place for
culinary enthusiasts to connect and celebrate their shared passion.

The commitment to excellence is deeply ingrained in Recipe World's DNA. The


website provides an intuitive and user-friendly interface, making it effortless
for users to browse recipes, search for specific dishes, and engage with the
vibrant community. Recipe World is constantly evolving to meet the evolving needs
of its users, regularly introducing new features and functionalities to enhance
the overall experience.

Recipe World is dedicated to upholding the highest standards of quality and


ensuring that the platform remains a trusted source for reliable and delectable
recipes. The team behind Recipe World comprises culinary experts, food
photographers, and experienced developers who work tirelessly to deliver an
exceptional user experience and maintain the website's reputation as a leading
destination for recipe sharing.

Looking ahead, Recipe World envisions a future where individuals from every
corner of the world can come together, sharing their culinary heritage,
exchanging ideas, and embracing the joy of cooking. The company is committed to
fostering a global community that celebrates the diversity of flavors and
encourages individuals to embark on their own culinary journeys. With Recipe
World, the possibilities in the world of recipes are endless.
</p>

Index.cshtml

@{
ViewData["Title"] = "Home Page";
}

<div class="text-center">
<h1 class="display-4">Welcome</h1>
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-
action="Index"><img src="~/Image\Recipe World logo.jpg" height="200px"
width="200px" /></a>

<p>
Welcome to Recipe World where

we share a collection of delicious

recipe. Here we believe that....


</p>
<p>
...DELICIOUS MAKE IT PRECIOUS!.
</p>

</div>

PopularItems.cshtml

@{
ViewData["Title"] = "Popular Items";
}
<h1>@ViewData["Title"]</h1>

Privacy.cshtml

@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>

<p>Our customers reserve the rights to keep their information confidential.</p>

Recipe.cshtml

@{
ViewData["Title"] = "Recipe";
}
<h1>@ViewData["Title"]</h1>
wwwroot

3. wwwroot> create new folder “image”> right-click image folder> open folder
in file explorer> copy logo image from laptop transfer to wwwroot image
file pastu tutup file explorer>. Wwwroot> right-click image file> click
image> check file path & copy dari image sampai habis

Lepas tu paste dkt merah yg dkt _layout.cshtml


Shared_layout

5. View> Shared>_Layout.cshtml

!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Recipe World</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-
white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-
action="Index"><img src="~/Image\Recipe World logo.jpg" height="70px"
width="70px"/></a>
<button class="navbar-toggler" type="button" data-bs-
toggle="collapse" data-bs-target=".navbar-collapse" aria-
controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-
content-between">
<ul class="navbar-nav flex-grow-1">

<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-
controller="Home" asp-action="Index">Home</a>
</li>

<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-
controller="Home" asp-action="Recipe">Recipe</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-
controller="Home" asp-action="PopularItems">Popular Items</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-
controller="Home" asp-action="AboutUs">About Us</a>
</li>

<li>
<input type="text" id="searchInput"
placeholder="Enter your search term" />
<button type="button"
onclick="search()">Search</button>
</li>

</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>

<footer class="border-top footer text-muted">


<div class="container">
&copy; 2023 - Recipe World - <a asp-area="" asp-controller="Home"
asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>

You might also like