Advertisement
Guest User

Zutaten.cshtml

a guest
Nov 15th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. @using MySql.Data.MySqlClient;
  2. @using System.Configuration;
  3. @{
  4. Layout = "~/_Layout.cshtml";
  5. // weiterer C# Code hier
  6. Page.Title = "E-Mensa";
  7. string conString = ConfigurationManager.ConnectionStrings["dbConStr"].ConnectionString;
  8. MySqlConnection con = new MySqlConnection(conString);
  9. con.Open();
  10. MySqlCommand cmd;
  11. try
  12. {
  13. cmd = con.CreateCommand();
  14. cmd.CommandText = "SELECT * FROM zutaten";
  15. MySqlDataReader r = cmd.ExecuteReader();
  16. <table>
  17. <tr>
  18. <th>Zutat</th>
  19. <th>Vegan?</th>
  20. <th>Vegetarisch?</th>
  21. <th>Glutenfrei?</th>
  22. </tr>
  23. @while (r.Read())
  24. {
  25. <tr>
  26. <td>
  27. @r["Name"]
  28. </td>
  29.  
  30. <td>
  31. @{ var yikes = 1;}
  32. @if (@*r["Vegan"] == 1*@ yikes == 1)
  33. {
  34. @:<i class="fas fa-check"></i>
  35. }
  36. else
  37. {
  38. @:<i class="fas fa-times"></i>
  39. }
  40. </td>
  41.  
  42. <td>
  43. @if (@*r["Vegetarisch"] == 1*@ yikes == 0){
  44. @:<i class="fas fa-check"></i>
  45. }
  46. else{
  47. @:<i class="fas fa-times"></i>
  48. }
  49. </td>
  50.  
  51. <td>
  52. @if (@*r["Glutenfrei"] == 1*@ yikes == 1)
  53. {
  54. @:<i class="fas fa-check"></i>
  55. }
  56. else
  57. {
  58. @:<i class="fas fa-times"></i>
  59. }
  60. </td>
  61. </tr>
  62. }
  63. @*r.Close();*@
  64. </table>
  65. }
  66. catch (Exception e)
  67. {
  68. //throw new Exception();
  69. <li>
  70. <p class="error">Das hat nicht geklappt.</p>
  71. <pre>@e.Message</pre>
  72. </li>
  73. }
  74. con.Close();
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement