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 });

        }
        public ActionResult UpdateInstructor(int? id)
        {
            if (User.IsInRole("Instructor"))
            {
                ProfileCommon profile = HttpContext.Profile as ProfileCommon;
                int memberId = profile.MemberId;
                InstructorData instructor = _dataService.GetInstructorInfoByMemberId(memberId);

                UpdateInstructorViewModel viewModel = null;
                if (instructor != null)
                {
                    viewModel = new UpdateInstructorViewModel(instructor);
                    if (instructor.AuthorizedAircraft != null && instructor.AuthorizedAircraft.Count > 0)
                        viewModel.AuthorizedAircraft = instructor.AuthorizedAircraft.Select(a => a.AircraftId).ToList();
                }
                else
                {
                    viewModel = new UpdateInstructorViewModel();
                }

                viewModel.MemberId = memberId;
                viewModel.AircraftList = GetAircraftList();

                return View(ViewNames.UpdateInstructor, viewModel);
            }
            else if (User.IsInRole("Admin"))
            {
                if (id == null)
                    throw new HttpException("Must have member ID");

                InstructorData instructor = _dataService.GetInstructorInfoByMemberId((int)id);
                UpdateInstructorViewModel viewModel = null;
                if (instructor != null)
                {
                    viewModel = new UpdateInstructorViewModel(instructor);
                    if (instructor.AuthorizedAircraft != null && instructor.AuthorizedAircraft.Count > 0)
                        viewModel.AuthorizedAircraft = instructor.AuthorizedAircraft.Select(a => a.AircraftId).ToList();
                }
                else
                {
                    viewModel = new UpdateInstructorViewModel();
                }
                    
                viewModel.MemberId = (int)id;
                viewModel.AircraftList = GetAircraftList();

                return View(ViewNames.UpdateInstructor, viewModel);
            }
            else
            {
                throw new HttpException(403, "You are not authorized to perform this operation.");
            }
        }