Hi,
Good day. I’m blocked on the additional challenge provided on the project for the Resume Templator on Skill path Build Web Apps with ASP.NET and would like some help to understand what is wrong with my code:
Link:
- Update the _Links.cshtml partial to use
Link
as the new model andURLPath
as the placeholder for the URL usernames. - Update the use of the partial in Index.cshtml and Projects.cshtml to use a new instance of
Link
and pass in the correct values forlinkType
andurlPath
in the constructor.
Here is my code:
Link.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace ResumeTemplater.Models
{
// Additional Challenge
public class Link : PageModel
{
public enum LinkType
{
Github,
LinkedIn
}
public LinkType Type;
public string URLPath { get; set; }
public Link(LinkType type, string urlPath)
{
this.Type = type;
this.URLPath = urlPath;
}
}
}
_Links.cs
<!-- _Links.cshtml -->
@model Link
<!-- Create partial below -->
@if (ViewData["Title"].ToString() == "Home")
{
<a class="navbar-brand justify-content-start"
asp-host="www.linkedin.com"
asp-controller="@Model.URLPath">LinkedIn</a>
}
else if (ViewData["Title"].ToString() == "Projects")
{
<a class="navbar-brand justify-content-start"
asp-host="www.github.com"
asp-controller="@Model.URLPath">Github</a>
}
Index.cshtml
@page
<!-- Index.cshtml -->
<!-- Add model directive below -->
@model IndexModel
@{
// Add ViewData Title below
ViewData["Title"] = "Home";
}
<div class="jumbotron jumbotron-fluid jumbotron-container resume-jumbotron text-white">
<div class="container-fluid jumbotron-content">
<p class="text-center jumbotron-header mb-4">Hey there, I'm @Model.FullName<!-- Your name here -->!</p>
</div>
</div>
<div class="container">
<div class="resume-content">
<h4 class="general-header mb-3">Summary:</h4>
<p class="general-content mb-3">I'm an enthusiastic software engineer with <!-- Years of experience -->@Model.YearsOfExperience+ years of experience participating in the complete lifecyclye of successfully launched applications. I am skilled in developing business plans, requirements specifications, user documentation, and architectural systems research. Strong written and verbal communications.</p>
</div>
<div class="resume-content">
<h4 class="general-header mb-3">Languages:</h4>
<ul class="list-group general-content">
@foreach(var language in @Model.Languages){
<li class="list-item" style="width: 18rem;">
<!-- Language -->
@language
</li>
}
</ul>
</div>
<div class="resume-content">
<h4 class="general-header mb-3">Contact</h4>
<p class="general-content">
<!-- Render partial for Link below -->
<p>For more information regaridng my experience, please refer to my <partial name="_Links" model="@new Link(LinkType.LinkedIn, Model.LinkedInUsername)"></p>
</p>
</div>
</div>
Project.cshtml
@page
<!-- Projects.cshtml -->
<!-- Add model directive below -->
@model ProjectsModel
@{
// Add ViewData Title below
ViewData["Title"] = "Projects";
}
<div class="jumbotron jumbotron-fluid jumbotron-container text-white project-jumbotron">
<div class="container-fluid jumbotron-content">
<p class="text-center mb-4 jumbotron-header">Projects</p>
</div>
</div>
<div class="container">
@foreach(var project in Model.Projects)
{
if(project.Year > 2017){
<div class="project-container">
<h4 class="project-title general-header">
<!-- Project Title -->
@project.Title
</h4>
<p class="project-year general-header">
<!-- Project Year -->
@project.Year
</p>
<p class="project-description general-content">
<!-- Project Description -->
@project.Description
</p>
<h5>Technologies</h5>
<ul class="general-header">
@foreach(string technology in @project.Technologies){
<li>@technology</li>
}
</ul>
</div>
}
}
<br>
<h4 class="general-header">Portfolio</h4>
<p class="general-content">
<!-- Render partial for Link below -->
<p>For more information regaridng my projects, please refer to my <partial name="_Links" for="@Model.GitHubUsername"></p>
</p>
<br>
</div>
Now the problem is, everytime I run my code, it throws an error about the name “LinkType” don’t exist. I’ve been racking my brains non-stop and can’t seem to find an accurate answer. Hope someone can help me.