Question: How can I connect and code the HomeController.cs and Model between my StaffRepository.cs and at the HomePage the in Index.cshtml without JQuery but with Ajax

How can I connect and code the HomeController.cs and Model between my StaffRepository.cs and at the HomePage the in Index.cshtml

without JQuery but with Ajax

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

DESCRIPTION

StaffRepository.cs contains these:

namespace Chegg.Infrastructure; public interface IStaffRepository { Staff Get(int id); } public class StaffRepository : IStaffRepository { public Staff Get(int id) { return AllStaff().First(x => x.Id == id); } private IEnumerable AllStaff() { return new Staff[] { new Staff() { Id = 101, FullName = "Bon Jovi", Email = "bonjovi@singer.com", JobTitle = "Singer", Likes = new [] {"Sing", "Play"} }, new Staff() { Id = 182, FullName = "Ed Sheeran", Email = "edsheeran@singer.com", JobTitle = "Great Singer" }, new Staff() { Id = 100, FullName = "Adele", Email = "adele@singer.com", Likes = new [] {"sing","cakes"} }, }; } } public class Staff { public int Id { get; set; } public string FullName { get; set; } public string Email { get; set; } public string JobTitle { get; set; } public string[] Likes { get; set; }

Index.cshtml contains these:

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

Staff List

Select to load

My file system is like this (sadly I could not upload here a photo so):

Main folder:

Chegg.Infrastructure folder

Chegg.UI folder

Chegg.sln Visual Studio Solution

etc.

In the Chegg.Infrastructure folder we can see:

bin folder

obj folder

Chegg.Infrastructure C# Project Source File

StaffRepository.cs C# Source File

etc.

In the Chegg.UI folder we can see the followings:

bin folder

Controllers folder

Models folder

obj folder

Properties folder

Views folder

www.root folder

etc.

Thanks so much for help with this example to me.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!