public ActionResult UpdateInstructor(UpdateInstructorViewModel viewModel) { InstructorData instructor = _dataService.GetInstructorInfoByMemberId(viewModel.MemberId); if (instructor == null) { instructor = new InstructorData(); } ProfileCommon profile = ProfileCommon.GetProfile(); instructor.MemberId = viewModel.MemberId; instructor.AvailableForCheckoutsAnnuals = viewModel.AvailableForCheckoutsAnnuals; instructor.CertificateNumber = viewModel.CertificateNumber; instructor.Ratings = viewModel.Ratings; instructor.InstructOnWeekdayNights = viewModel.InstructOnWeekdayNights; instructor.InstructOnWeekdays = viewModel.InstructOnWeekdays; instructor.InstructOnWeekends = viewModel.InstructOnWeekends; instructor.Comments = viewModel.Comments; if (User.IsInRole(UserRoles.Admin.ToString())) { instructor.DesignatedForStageChecks = viewModel.DesignatedForStageChecks; if (viewModel.AuthorizedAircraft.Count > 0) { if (instructor.AuthorizedAircraft == null) { instructor.AuthorizedAircraft = new List <InstructorAuthorization>(); } foreach (var acId in viewModel.AuthorizedAircraft) { if (instructor.AuthorizedAircraft.Any(aa => aa.AircraftId == acId)) { continue; } InstructorAuthorization auth = new InstructorAuthorization() { AircraftId = acId, InstructorId = viewModel.Id, AuthorizedOn = DateTime.Now, AuthorizedById = profile.MemberId }; instructor.AuthorizedAircraft.Add(auth); } } } _dataService.SaveInstructor(instructor); //Member member = _dataService.GetMember(instructor.MemberId); //InstructorViewModel instructorVM = new InstructorViewModel() //{ // MemberId = instructor.MemberId, // AltPhone = member.Phone, // AvailableForCheckoutsAnnuals = instructor.AvailableForCheckoutsAnnuals, // InstructOnWeekdayNights = instructor.InstructOnWeekdayNights, // InstructOnWeekdays = instructor.InstructOnWeekdays, // InstructOnWeekends = instructor.InstructOnWeekends, // CeritifcateNumber = instructor.CertificateNumber, // Comments = instructor.Comments, // DesignatedForStageChecks = instructor.DesignatedForStageChecks, // Email = member.Login.Email, // FullName = member.FullName, // Id = instructor.Id, // Phone = member.Phone, // Ratings = instructor.Ratings //}; return(RedirectToAction("InstructorDetails", new { memberId = instructor.MemberId })); }