Пример #1
0
 public ActionResult MentorRequest()
 {
     var studentId = CurrentUserId;
     var model = new MentorRequestVm
     {
         StudentId = studentId,
     };
     return View(model);
 }
Пример #2
0
 public ActionResult MentorRequest(MentorRequestVm model)
 {
     if (ModelState.IsValid)
     {
         var student = CurrentUser;
         var mentor = new MentorShip
         {
             StartDate = DateTime.UtcNow,
             AlumniId = 0,
             StudentId = model.StudentId,
             AlumniName = "NA",
             StudentName = student.FullName,
         };
         var message = new MentorMessage
         {
             Status = mentor.Status,
             SenderId = student.UserId,
             Date = DateTime.UtcNow,
             Text = model.Message,
             MentorShipId = mentor.MentorShipId,
             SenderName = student.FullName
         };
         _db.MentorShips.Add(mentor);
         _db.MentorMessages.Add(message);
         _db.SaveChanges();
         model.IsDone = true;
     }
     return View(model);
 }