public async Task <string> Handle(AddAppProfileCommand request, CancellationToken cancellationToken) { var locationDetails = LocationDetails.Create(string.Empty, string.Empty, string.Empty); var personalDetails = PersonalDetails.Create(request.UserId, request.Email, string.Empty, string.Empty, string.Empty, locationDetails); var instructorDetails = InstructorDetails.Create(null); var appDetails = AppDetails.Create(AccountType.STUDENT, DateTime.UtcNow, DateTime.UtcNow, new List <SubscriptionDetails>(), instructorDetails); var profile = Model.Profile.Create(string.Empty, DateTime.UtcNow, personalDetails, appDetails); var mapper = new Mapper(_mapperConfiguration); var dao = mapper.Map <ProfileDAO>(profile); try { await _db.Profile.InsertOneAsync(dao); } catch (Exception) { return(string.Empty); } return(dao.Id.ToString()); }
// GET: Instructor/Details/5 public async Task <IActionResult> Details(int?id, int?courseID) { if (id == null) { return(NotFound()); } var viewModel = new InstructorDetails(); //Get the instructor var instructor = await _context.Instructors .Include(i => i.CourseAssignments)//We need to get the course and department .ThenInclude(i => i.Course) .ThenInclude(i => i.Department) .Include(x => x.OfficeAssignment)//Because we need to get the location .FirstOrDefaultAsync(x => x.ID == id); if (instructor == null) { return(NotFound()); } viewModel.CourseTaughtByCurrentInstructor = instructor.CourseAssignments.Select(x => x.Course); //All Courses taught by this instructor if (courseID != null) { ViewData["CourseID"] = courseID; //use explicit loading so we load the enrollment data only if it's requested var selectedCourse = viewModel.CourseTaughtByCurrentInstructor.Where(x => x.CourseID == courseID).Single(); await _context.Entry(selectedCourse).Collection(x => x.Enrollments).LoadAsync(); foreach (Enrollment enrollment in selectedCourse.Enrollments) { await _context.Entry(enrollment).Reference(x => x.Student).LoadAsync(); } viewModel.AllEnrollmentFromCurrentCourse = selectedCourse.Enrollments; //Get Enrollments related to this course } viewModel.CurrentInstructor = instructor; //Get This instructor return(View(viewModel)); }