そのため、ログインしたユーザーのみが自分で休日を予約できるようにしたいと考えています。これを行う最も簡単な方法は、ログインしているユーザーの「名前」と個人テーブルの「名前」を比較することだと思います。そう....
public ActionResult Create()
{
string xx = (string)Session["usernameID"];
int? currentPersonID = Convert.ToInt32(xx);
string userNameComparedAgainstLoginName = // here is where i want to say 'name' of logged in user
CreateModel model = new CreateModel();
model.currentPersonID = currentPersonID.Value;
model.PList4DD = db.People.ToList();
if (userNameComparedAgainstLoginName == model.userName)
{
ViewBag.Id = new SelectList(db.People, "Id", "Name");
return View(model);
}
else
{
TempData["canOnlyBookHolidaysForYourself"] = "I'm afraid you can only book holidays for yourself";
return RedirectToAction("Index");
}
}
ユーザー登録時に指定された名前は、データベースで使用されている名前と同じになります。
ログインした「名前」にアクセスする方法を誰か教えてもらえますか?
ありがとう