// GET: Interviews/Create public ActionResult Create() { CreateInterviewVM model = new CreateInterviewVM(); model.sessions = new SelectList(db.InterviewSessions, "SessionID", "SessionName"); model.students = new SelectList(db.Students, "StudentID", "StudentName"); model.EmplList = db.Employees.ToList <Employee>(); return(View(model)); }
public async Task <IActionResult> Create(CreateInterviewVM model) { var filePath = this.env.WebRootPath + "/tasks/55.jpg"; using (var stream = new FileStream(filePath, FileMode.CreateNew)) { await model.File.CopyToAsync(stream); } return(this.Redirect("/")); }
public ActionResult Create(CreateInterviewVM model, FormCollection collection) { Interview interview = new Interview(); if (ModelState.IsValid) { string student = model.studentID; string session = model.sessionID; interview.StudentID = Convert.ToInt32(student); interview.SessionID = Convert.ToInt32(session); interview.InterviewDate = Convert.ToDateTime(collection["date"].ToString()); interview.Room = model.roomNumber; interview.OverallComment = "Interview not yet started"; List <Employee> List = db.Employees.ToList(); db.Interviews.Add(interview); foreach (Employee E in List) { try { if (collection[E.EmployeeID.ToString()].ToString().Equals("on")) { ; } { PanelMember member = new PanelMember(); member.InterviewID = interview.InterviewID; member.Interview = interview; member.EmployeeID = E.EmployeeID; Employee emp = db.Employees.FirstOrDefault(e => e.EmployeeID == E.EmployeeID); member.Employee = emp; db.PanelMembers.Add(member); } } catch (Exception) { } } db.SaveChanges(); return(RedirectToAction("Index")); } model.students = new SelectList(db.Students, "StudentID", "StudentName", model.studentID); model.sessions = new SelectList(db.InterviewSessions, "SessionID", "SessionName", model.sessionID); //model.panelMembers = new SelectList(db.Employees, "EmployeeID", "EmployeeName", model.panelMemberID); return(View(interview)); }