Skip to content

Parte 15

WILSON DE OLIVEIRA JUNIOR edited this page Mar 9, 2020 · 1 revision

Parte 15

Criando a página Categoria Item.

  1. No projeto Taste.Web dentro da pasta Category (Taste.Web\Pages\Settings\Category), crie uma nova Razor Page chamada Item:
  • Crie o arquivo Item.cshtml.cs com o seguinte conteudo:
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Taste.Web.Pages.Settings.Category
{
    public class ItemModel : PageModel
    {
        public void OnGet()
        {
        }
    }
}
  • Crie o arquivo Item.cshtml com o seguinte conteudo:
@page
@model Taste.Web.Pages.Settings.Category.ItemModel
@{
    ViewData["Title"] = "Categoria";
    Layout = "~/Pages/Shared/_Layout.cshtml";
}
<h1>Nova Categoria</h1>
  1. Altere o arquivo index.cshtml com o seguinte conteudo:
@page
@model Taste.Web.Pages.Settings.Category.IndexModel
@{
    ViewData["Title"] = "Categorias";
    Layout = "~/Pages/Shared/_Layout.cshtml";
}
<div class="border backgroundWhite container">
    <div class="row">
        <div class="col-6">
            <h2 class="text-primary">Categorias</h2>
        </div>
        <div class="col-6 text-right">
            <a asp-page="Item" class="btn btn-primary">
                <i class="fas fa-plus"></i>
                Nova categoria
            </a>
        </div>
    </div>
</div>

Clone this wiki locally