-
-
Save JohannesSundqvist/81cb7778b0d0336560d336020d8826f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 0; i < ViewData["CustomerNameFromCode"].ToString().Distinct().Count(); i++) { | |
// returns 6 for some reason | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Customer GetCustomerData(string code) | |
{ | |
var query = (from a in Customers | |
where a != null && a.Code == code | |
select a).FirstOrDefault(); | |
return query; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IDataContext | |
{ | |
Customer GetCustomerData(string code); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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