【发布时间】:2017-03-24 08:52:26
【问题描述】:
我有面试和Interwier
当我创建采访时,我需要在 View 中生成链接并将其发送给 interwier。
所以如果 Interview_id 是=5 Interviewer 将被采访, interview id=5
Table Intervier 与 Interview table 链接
这是面试官桌
CREATE TABLE [dbo].[Interwiers] (
[Interwier_id] INT IDENTITY (1, 1) NOT NULL,
[FIO] NVARCHAR (MAX) NULL,
[Email] NVARCHAR (MAX) NULL,
[Telephone] NVARCHAR (MAX) NULL,
[Birthday] DATETIME NOT NULL,
[City] NVARCHAR (MAX) NULL,
[Salary] NVARCHAR (MAX) NULL,
[English] NVARCHAR (MAX) NULL,
[Interview_Id] INT NULL,
[Status] NVARCHAR (MAX) NULL,
PRIMARY KEY CLUSTERED ([Interwier_id] ASC),
CONSTRAINT [FK_Interwiers_ToTable] FOREIGN KEY ([Interview_Id]) REFERENCES [dbo].[Interviews] ([Interview_Id]) ON DELETE CASCADE
现在我生成像 http://localhost:51542/Interwier/Welcome 这样的链接,我需要像这样的 'http://localhost:51542/Interwier/Welcome/5' 所以如果 Interwier 在 Interview_Id 的表中自动填充数据,例如 id=5。
我怎么能意识到这一点?
也许我没有清楚地写下我的问题。如果没有,不清楚的告诉我,我会编辑它
更新
这是 Interwier 的控制器,这里我将数据写入表
public ActionResult Welcome()
{
return View();
}
// POST: Interwier/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Welcome([Bind(Include = "Id,FIO,Email,Telephone,Birthday,City,English,Salary")] Interwier interwierModel)
{
if (ModelState.IsValid)
{
db.InterwierModels.Add(interwierModel);
db.SaveChanges();
return RedirectToAction("WebCamCheck");
}
return View(interwierModel);
}
更新2
我试着写逻辑
这是开始屏幕,我在这里创建面试(选择空缺并写下有关面试的详细信息),所以我创建了 Interwiev id。完成了。
之后我创建问题并将它们添加到面试中,然后单击下一步并将问题添加到表格中并链接到 Interview_id
这是样机
之后我需要向人们发送邀请。还有下一个样机
在 Link 我需要生成 Link to interview ,而不是像我之前写的那样。
我需要用 id 生成它。因此,用户打开它并填写有关他的信息,它将链接到此面试 ID。
【问题讨论】:
标签: asp.net asp.net-mvc asp.net-mvc-4 routing