Skip to content

ASP.NET Core sample Web App that executes CRUD and user authentication (Login/register) operations on a database using Entity Framework Core

Notifications You must be signed in to change notification settings

DanielHzp/CustomerLoginCRUDWebApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

CustomerLoginCRUDWebApp

ASP.NET Core sample Web App that executes CRUD and user authentication (Login/register) operations on a database using Entity Framework Core. Basic bootstrap classes are used to interface data with the following user views. One controller is used to create six views that interface with the user comments data model. One custom view is manually created for the search form tab and different controller methods are manipulated to add custom CRUD functionalities (create, update, read, delete)


## Main Controller Methods Some controller methods are customized to resemble data search functionalities:
// GET: UserComments
//Item that is going to show all comments
public async Task<IActionResult> Index()
{
return _context.UserComment != null ?
View(await _context.UserComment.ToListAsync()) :
Problem("Entity set 'ApplicationDbContext.UserComment' is null.");
}


// GET: UserComments/Show search form
//If the URL contains this method name, the following command is executed with this controller
public async Task<IActionResult> SearchFormView()
{
//We need to create search form VIEW in views folder
return View(); //Go find the view with given name
}
// POST: UserComments/Show search form RESULTS
//If the URL contains this method name, the following command is executed with this controller
// public string DisplaySearchResults(String SearchInput)
public async Task<IActionResult> DisplaySearchResults(String SearchInput)
{
//Return message with searched input public string .....
//return "You searched for: "+ SearchInput;
//We want to return a list of filtered results from the Index table
return View("Index", await _context.UserComment.Where(j=>j.CommentDescription.Contains(SearchInput)).ToListAsync()); //Go to index view and search the input string
}


// POST: UserComments/Create ADD NEW COMMENTS TO DATABASE!!!!
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
// [Authorize]
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,CommentDescription,Details")] UserComment userComment)
{
if (ModelState.IsValid)
{
_context.Add(userComment);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(userComment);
}


Layout



























About

ASP.NET Core sample Web App that executes CRUD and user authentication (Login/register) operations on a database using Entity Framework Core

Topics

Resources

Stars

Watchers

Forks