public ActionResult PilotLogBook(int pilotId, bool buttonEnable = false)
        {
            //pilotid = pilotId;
            //try
            //    {
            if (Request.IsAuthenticated)
            {
                ViewBag.ViewTitle  = "My LogBook";
                ViewBag.ActionBack = "Index";

                q.pilotId = pilotId;
                var p = q.pilotEntity;
                if (p == null)
                {
                    return(View("LogBookNotFound"));
                }
                var logBookList = q.pilotLogBook.ToList();

                var timeLogBook = logBookList.Sum(item => item.FlightDurationMin) / 60;
                var timeForward = p.TimeForward;// q.pilotTimeForwarded;

                ViewBag.TimeForward      = timeForward;
                ViewBag.LogBookTimeHours = timeLogBook;
                ViewBag.TotalTimeHours   = timeForward + timeLogBook;

                var landNumForward = p.LandingsForward;// q.pilotLandingsForwarded;
                var landNumLogBook = logBookList.Sum(item => item.NoLandings);

                ViewBag.LandNumForward = landNumForward;
                ViewBag.LandNumLogBook = landNumLogBook;
                ViewBag.LandNumTotal   = landNumForward + landNumLogBook;

                ViewBag.VLBReadyToDownload = buttonEnable;

                var vmpilotlogbook = new vmPilotLogBook(logBookList, pilotId, timeForward, landNumForward);
                return(View(vmpilotlogbook));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
            //}
            //catch (Exception e)
            //{
            //    //ViewBag.ExceptionErrorMessage = debugmode ? e.Message : "Database Exception";
            //    return View("LogBookNotFound");
            //}
        }
        public ActionResult PilotLogBookMobile(string pilotUserName)
        {
            ViewBag.PilotUserName = pilotUserName;
            q.pilotUserName       = pilotUserName;
            //var p = db.Pilots.Where(r => r.PilotUserName.Equals(pilotUserName)).FirstOrDefault();
            var p = q.pilotEntity;

            if (p == null)
            {
                return(View("LogBookNotFound"));
            }

            //pilotid = p.PilotID;
            //ViewBag.PilotId = p.PilotID;
            ViewBag.ViewTitle  = "My LogBook";
            ViewBag.ActionBack = "Index";
            //var logBookList = q_flightsLogBook.ToList();

            var logBookList = q.pilotLogBook.ToList();
            var timeLogBook = logBookList.Sum(item => item.FlightDurationMin) / 60;
            //var timeForward = db.Pilots.Where(r => r.PilotID == pilotid).FirstOrDefault().TimeForward;
            var timeForward = p.TimeForward;// q.pilotTimeForwarded;

            ViewBag.TimeForward      = timeForward;
            ViewBag.LogBookTimeHours = timeLogBook;
            ViewBag.TotalTimeHours   = timeForward + timeLogBook;

            //var landNumForward = db.Pilots.Where(r => r.PilotID == pilotid).FirstOrDefault().LandingsForward; ;
            var landNumForward = p.LandingsForward;// q.pilotLandingsForwarded;
            var landNumLogBook = logBookList.Sum(item => item.NoLandings);

            ViewBag.LandNumForward = landNumForward;
            ViewBag.LandNumLogBook = landNumLogBook;
            ViewBag.LandNumTotal   = landNumForward + landNumLogBook;

            //List<vPilotLogBook> logBookRecords = q_flightsLogBook.ToList();

            var vmpilotlogbook = new vmPilotLogBook(logBookList, q.pilotId, timeForward, landNumForward);

            return(View(vmpilotlogbook));
        }