Skip to content

Instantly share code, notes, and snippets.

@JohannesSundqvist
Created September 5, 2016 06:18
Show Gist options
  • Save JohannesSundqvist/81cb7778b0d0336560d336020d8826f0 to your computer and use it in GitHub Desktop.
Save JohannesSundqvist/81cb7778b0d0336560d336020d8826f0 to your computer and use it in GitHub Desktop.
for (int i = 0; i < ViewData["CustomerNameFromCode"].ToString().Distinct().Count(); i++) {
// returns 6 for some reason
}
public Customer GetCustomerData(string code)
{
var query = (from a in Customers
where a != null && a.Code == code
select a).FirstOrDefault();
return query;
}
public interface IDataContext
{
Customer GetCustomerData(string code);
}
public IActionResult CustomerPage(string code)
{
try
{
var NameQuery = _context.GetCustomerData(code).Name;
ViewData["CustomerNameFromCode"] = NameQuery;
return View();
}
catch
{
return RedirectToAction("Login");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment