public ActionResult DeleteConfirmed(int id) { TraitComment traitComment = db.TraitComments.Find(id); db.TraitComments.Remove(traitComment); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TraitCommentID,PanelID,TraitID,Comment,Score")] TraitComment traitComment) { if (ModelState.IsValid) { db.Entry(traitComment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PanelID = new SelectList(db.PanelMembers, "PanelID", "PanelID", traitComment.PanelID); ViewBag.TraitID = new SelectList(db.TraitCategories, "TraitID", "TraitName", traitComment.TraitID); return(View(traitComment)); }
// GET: TraitComments/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TraitComment traitComment = db.TraitComments.Find(id); if (traitComment == null) { return(HttpNotFound()); } return(View(traitComment)); }
// GET: TraitComments/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TraitComment traitComment = db.TraitComments.Find(id); if (traitComment == null) { return(HttpNotFound()); } ViewBag.PanelID = new SelectList(db.PanelMembers, "PanelID", "PanelID", traitComment.PanelID); ViewBag.TraitID = new SelectList(db.TraitCategories, "TraitID", "TraitName", traitComment.TraitID); return(View(traitComment)); }
public ActionResult StartInterview(StartInterviewVM model) { if (Session["userLoggedIn"] == null) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { try { String interviewID = ""; if (Session["CurrentInterview"] != null) { interviewID = Session["currentInterview"].ToString(); } int idVal = Convert.ToInt32(interviewID); Interview interview = db.Interviews.Find(idVal); //get all panelMembers for this interview model.panelMembers = new List <PanelMember>(); var panelMembers = db.PanelMembers.ToList().Where(p => p.InterviewID == interview.InterviewID); model.employees = new List <Employee>(); foreach (PanelMember p in panelMembers) { model.panelMembers.Add(p); model.employees.Add(p.Employee); } //get the current panel member that is scoring this interview from the logged in user session. string loggedInUser = Session["userLoggedIn"].ToString(); //email address //if(panelMembers.FirstOrDefault(p => p.Employee.EmployeeEmail == loggedInUser) == null) //{ // return RedirectToAction("Index", "Home"); //} //we need to construct an overall comment from all the panel members' overall comments. Currently the overall comment gets replaced if (Request["overallComment"] != null) { interview.OverallComment = Request["overallComment"].ToString(); } foreach (TraitCategory category in db.TraitCategories) { string name = category.TraitName; TraitComment comment = new TraitComment(); string score = ""; string commentText = ""; if (Request[name + "Score"] != null) { score = Request[name + "Score"].ToString(); } comment.Score = Convert.ToInt32(score); if (Request[name + "Comment"] != null) { commentText = Request[name + "Comment"].ToString(); } comment.Comment = commentText; comment.TraitID = category.TraitID; comment.TraitCategory = category; comment.PanelMember = model.panelMembers.FirstOrDefault(); comment.PanelID = comment.PanelMember.PanelID; db.TraitComments.Add(comment); } //add the panel member's score to the appropriate row var member = model.panelMembers.First(); if (Request["panelScore"] != null) { string panelScore = Request["panelScore"].ToString(); member.PannelScore = Convert.ToInt32(panelScore); } db.SaveChanges(); var panelScores = from p in db.PanelMembers where p.InterviewID == interview.InterviewID select p.PannelScore; interview.OverallScore = totalScoreCalc(panelScores); db.SaveChanges(); model.interview = interview; model.Student = interview.Student; } catch (NullReferenceException ex) { Console.WriteLine("Aw shucks we done messed up " + ex.Message); } } else { try { String interviewID = ""; if (Session["CurrentInterview"] != null) { interviewID = Session["currentInterview"].ToString(); } int idVal = Convert.ToInt32(interviewID); Interview interview = db.Interviews.Find(idVal); model.interview = interview; } catch (Exception ex) { Console.WriteLine("Couldn't find the interview " + ex.Message); } } model.categories = new List <TraitCategory>(db.TraitCategories); return(RedirectToAction("Leaderboard")); }