Last active
August 20, 2020 11:42
-
-
Save douglasstarnes/495e0f6c329b2c87851b0afef597d32d 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
<li class="nav-item"> | |
<a class="nav-link text-dark" | |
asp-area="" asp-page="/Questions/Index">Questions</a> | |
</li> | |
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
modelBuilder.Entity<Question>().HasData( | |
new List<Question>() { | |
new Question { | |
QuestionId = 1, | |
QuestionTitle = "First Question", | |
QuestionText = "About First Question", | |
Created = DateTime.Now, | |
Edited = DateTime.Now | |
}, | |
new Question { | |
QuestionId = 2, | |
QuestionTitle = "Second Question", | |
QuestionText = "About Second Question", | |
Created = DateTime.Now, | |
Edited = DateTime.Now | |
} | |
} | |
); | |
} | |
@if(Model.Questions.Count == 0) | |
{ | |
<div class="alert alert-info" role="alert">No questions found!</div> | |
} | |
else | |
{ | |
<table class="table table-striped"> | |
<thead class="thead-dark"> | |
<tr> | |
<th scope="col">Title</th> | |
<th scope="col">Answers</th> | |
<th scope="col">Ratings</th> | |
</tr> | |
</thead> | |
@foreach(var question in Model.Questions) | |
{ | |
<tr> | |
<td>@question.QuestionTitle</td> | |
<td></td> | |
<td></td> | |
</tr> | |
} | |
</table> | |
} | |
<div class="form-group"> | |
<label asp-for="@Model.Question.QuestionTitle"></label> | |
<input class="form-control" asp-for="@Model.Question.QuestionTitle" /> | |
</div> | |
<div class="form-group"> | |
<label asp-for="@Model.Question.QuestionText"></label> | |
<textarea class="form-control" asp-for="@Model.Question.QuestionText"></textarea> | |
</div> | |
private readonly QuandaDbContext context; | |
public CreateModel(QuandaDbContext context) | |
{ | |
this.context = context; | |
} | |
[Display(Name="Title")] | |
public string QuestionTitle { get; set; } | |
[Display(Name="Description")] | |
public string QuestionText { get; set; } | |
<div class="form-group"> | |
<label asp-for="@Model.Question.QuestionTitle"></label> | |
<input class="form-control" asp-for="@Model.Question.QuestionTitle" /> | |
<span class="font-weight-bold text-danger" asp-validation-for="@Model.Question.QuestionTitle"></span> | |
</div> | |
<div class="form-group"> | |
<label asp-for="@Model.Question.QuestionText"></label> | |
<textarea class="form-control" asp-for="@Model.Question.QuestionText"></textarea> | |
<span class="font-weight-bold text-danger" asp-validation-for="@Model.Question.QuestionText"></span> | |
</div> | |
<div> | |
<b>Title:</b><br/> | |
<span>@Model.Question.QuestionTitle</span> | |
</div> | |
<div> | |
<b>Description:</b><br/> | |
<span>@Model.Question.QuestionText</span> | |
</div> | |
<div> | |
<b>Created:</b><br/> | |
<span>@Model.Question.Created.ToShortDateString() @Model.Question.Created.ToShortTimeString()</span> | |
</div> | |
<div> | |
<b>Edited:</b><br/> | |
<span>@Model.Question.Edited.ToShortDateString() @Model.Question.Edited.ToShortTimeString()</span> | |
</div> | |
<a asp-page="./Details" asp-route-questionId="@question.QuestionId"> | |
@question.QuestionTitle | |
</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment