public void AssignMentor() { //Arrange var mockRepo = new MockMenteeRepository(); var manager = new MenteeManager(mockRepo); //Test Data var mentee = new MenteeModel { Category = "Art" }; //Act manager.AddMentee(mentee, 1); manager.AssignMentor(mentee, 11); //Assert Assert.IsTrue(mockRepo.Mentored(mentee.UserId), "Mentor was not assigned"); }
public ActionResult Assign(AssignViewModel model) { var mentee = model.Mentee; mentee = _mentee.GetMentee(mentee.UserId); var mentor = model.Mentor; var mentors = _mentor.GetMentorsByCategory(mentee.Category); ViewBag.UserId = new SelectList(mentors, "UserId", "User.Name", model.Mentor.UserId); try { _mentee.AssignMentor(mentee, mentor.UserId); return(RedirectToAction("notmentored")); } catch (Exception ex) { ModelState.AddModelError("invalid", ex.Message); } return(View(model)); }