我要做什么:
我正在尝试添加到候选历史记录(描述和标题,以及DateTime.Now),这是我想要的图像和我要做的事情的图像表示:
当选择选项为“ 候选人”时,如何将时间线添加到左侧;当选择选项为“ 日立”时,如何将时间线添加到右侧?将timeline-Inverted
添加到<li> Class
。
我现在所拥有的:
@model HCCBPOHR.Data.Candidate
@{
ViewData["Title"] = "CandidateHistory";
}
<h2>Canidate - @Model.Name</h2>
<label>History</label>
<hr />
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-clock-o fa-fw"></i> History Of @Model.Name
</div>
<div class="panel-body">
<ul class="timeline">
<li>
@* <li class="timeline-inverted">*@
@*Isto é para inverter o lado*@
<div class="timeline-badge">
<i class="fa fa-check"></i>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title">Title</h4>
<p>
<small class="text-muted"><i class="fa fa-clock-o"></i> @Model.DateOfDescription.ToShortDateString()</small>
</p>
</div>
<div class="timeline-body">
<p>@Model.Description</p>
</div>
</div>
</li>
</ul>
</div>
</div>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@Model.Saving"> Add History Description</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<form asp-action="CandidateHistory">
<div class="form-group">
<label asp-for="Title" class="control-label"></label>
<input asp-for="Title" class="form-control" />
<span asp-validation-for="Title" class="text-danger">
</span>
</div>
<div class="form-group">
<label asp-for="Description" class="control-label">
</label>
<input asp-for="Description" class="form-control" />
<span asp-validation-for="Description" class="text-danger"></span>
</div>
<div class="form-group">
<label>Selects</label>
<select asp-for="Saving" class="form-control">
<option value="false">Candidate </option>
<option value="true">Hitachi</option>s
</select>
</div>
<div class="form-group">
<label class="control-label">@DateTime.Now.ToShortDateString()</label>
@*<input asp-for="DateOfDescription" class="form-group" disabled />*@
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-
dismiss="modal">Close</button>
<div class="form-group">
<input type="submit" value="Add Description!" class="btn btn-
default" />
</div>
</div>
</div>
</div>
</div>
这也是我的控制器中的内容:
public IActionResult CandidateHistory(int Id)
{
using (var applicationcontext = new ApplicationContext())
{
var candidate = applicationcontext.Candidates.Single(q => q.Id == Id);
return View(candidate);
}
}
[HttpPost, ActionName("CandidateHistory")]
[ValidateAntiForgeryToken]
public IActionResult CandidateHistoryPost([Bind("Description")] Candidate candidate)
{
if (ModelState.IsValid)
{
using (var context = new ApplicationContext())
{
var CandidatefromDB = context.Candidates.Include(q => q.Description);
}
candidateRepository.Add(candidate);
candidateRepository.SaveChanges();
return RedirectToAction("Candidate");
}
return View();
}
这是我的模型课:
public class Candidate : BaseEntity
{
public int Id { get; set; }
public string Name { get; set; }
public int Number { get; set; }
public string ProfileText { get; set; }
public Byte[] CV { get; set; }
public string CVNAME { get; set; }
public List<Profile> ProfileList { get; set; }
public String Description { get; set; }
public Boolean Saving { get; set; }
public string Title { get; set; }
public DateTime DateOfDescription { get; set; }
}