public ActionResult Create(InterviewViewModel model) { //return null; if (this.ModelState.IsValid) { // model.AuthorId = this.User.Identity.GetUserId(); db.Interviews.Add(new Interview() { //AuthorId = model.AuthorId, Title = model.Title, Description = model.Description//, //DatePublic = DateTime.Now }); db.SaveChanges(); this.TempData["message"] = "Interview added successfylly."; this.TempData["isMessageSuccess"] = true; return RedirectToAction("Index", "Home"); } this.TempData["message"] = "There is a problem with the creation of this interview. Please try again later."; this.TempData["isMessageSuccess"] = false; // this.ViewBag.AuthorId = new SelectList(db.Users, "Id", "FullName", model.AuthorId); return View("Interviews/Create", model); }
//GET : Interviews/Details/id public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var interview = db.Interviews.Find(id); //(from interview in db.Interviews // where interview.Id == id // select interview).Take(1).ToList(); var outputInterview = new InterviewViewModel { Id= interview.Id, Title = interview.Title, Description = interview.Description//, // DatePublic = interview.DatePublic }; if (interview == null) { return RedirectToAction("PageNotFound","Home"); } return this.PartialView("_Interview", outputInterview); }