private List <ApprovalsData> GetApprovalsDataList(string groupName)
        {
            ApprovalsDataList = new List <ApprovalsData>();

            var spannerQuery = _flightSpannersData.GetSpannersByGroupName(groupName);

            //Approval approval;
            AircraftType   aircraftType;
            ApprovalDetail approvalDetail;

            foreach (var spanner in spannerQuery)
            {
                var approvalsDataQuery = _flightSpannersData.GetApprovalBySpannerCode(spanner.SpannerCode);

                foreach (var approval in approvalsDataQuery)
                {
                    aircraftType   = _flightSpannersData.GetAircraftTypeByAircraftTypeId(approval.AircraftTypeId);
                    approvalDetail = _flightSpannersData.GetApprovalDetailByApprovalDetailId(approval.ApprovalDetailId);

                    ApprovalsDataList.Add(new ApprovalsData {
                        ApprovalId       = approval.ApprovalId,
                        SpannerCode      = spanner.SpannerCode,
                        SpannerName      = spanner.SpannerFName + " " + spanner.SpannerM1Name,
                        SpannerLicenseNo = spanner.SpannerLicenseNo,
                        AircraftModel    = aircraftType.AircraftModel,
                        EngineModel      = aircraftType.EngineModel,
                        ApprovalRating   = approvalDetail.ApprovalRating,
                        ApprovalCategory = approvalDetail.ApprovalCategory
                    });
                }
            }
            return(ApprovalsDataList);
        }
        //Initialize SpannersDataDetailViewModel Properties
        public void SetApprovalsDataDetailViewModelProperties(int approvalId)
        {
            var currentGroup = _httpContext.HttpContext.User.FindFirst(ClaimTypes.GroupSid).Value;

            Approval       approval       = _flightSpannersData.GetApprovalByApprovalId(approvalId);
            Spanner        spanner        = _flightSpannersData.GetSpannerByCode(approval.SpannerCode);
            AircraftType   aircraftType   = _flightSpannersData.GetAircraftTypeByAircraftTypeId(approval.AircraftTypeId);;
            ApprovalDetail approvalDetail = _flightSpannersData.GetApprovalDetailByApprovalDetailId(approval.ApprovalDetailId);

            GroupName = currentGroup;

            ApprovalId       = approvalId;
            SpannerCode      = approval.SpannerCode;
            SpannerLicenseNo = spanner.SpannerLicenseNo;
            SpannerName      = spanner.SpannerFName + " " + spanner.SpannerM1Name;

            AircraftTypeId       = aircraftType.AircraftTypeId;
            AircraftModel        = aircraftType.AircraftModel;
            EngineModel          = aircraftType.EngineModel;
            AircraftTypeConstant = aircraftType.AircraftTypeConstant;

            ApprovalDetailId = approvalDetail.ApprovalDetailId;
            ApprovalRating   = approvalDetail.ApprovalRating;
            ApprovalCategory = approvalDetail.ApprovalCategory;
            ApprovalConstant = approvalDetail.ApprovalConstant;
        }
        //Initialize FlightRecordViewModel Properties
        public void SetFlightRecordDetailViewModelProperties(int flightRecordId)
        {
            //if (!flightRecordId.HasValue)
            //return;

            var currentGroup = _httpContext.HttpContext.User.FindFirst(ClaimTypes.GroupSid).Value;

            FlightRecord flightRecord;

            FlightData     flightData;
            AircraftType   aircraftType;
            Approval       approval;
            ApprovalDetail approvalDetail;
            Spanner        spanner;

            flightRecord = _flightSpannersData.GetFlightRecordByFlightRecordId(flightRecordId);
            flightData   = _flightSpannersData.GetFlightDataByFlightDataId(flightRecord.FlightDataId);
            aircraftType = _flightSpannersData.GetAircraftTypeByAircraftTypeId(flightRecord.AircraftTypeId);

            if (flightRecord.ApprovalId.HasValue)
            {
                approval              = _flightSpannersData.GetApprovalByApprovalId(flightRecord.ApprovalId);
                approvalDetail        = _flightSpannersData.GetApprovalDetailByApprovalDetailId(approval.ApprovalDetailId);
                spanner               = _flightSpannersData.GetSpannerByCode(approval.SpannerCode);
                SpannerCode           = spanner.SpannerCode;
                SpannerName           = spanner.SpannerFName + " " + spanner.SpannerM1Name;
                ApprovalRating        = approvalDetail.ApprovalRating;
                ApprovalCategory      = approvalDetail.ApprovalCategory;
                ApprovalDetailSummary = SpannerName + " ," + SpannerCode + " ," + ApprovalRating + " ," + ApprovalCategory;
                ApprovalConstant      = approvalDetail.ApprovalConstant;
            }

            RecordId             = flightRecord.FlightRecordId;
            RecordDate           = flightRecord.RecordDate;
            RecordTime           = flightRecord.RecordTime;
            FlightDate           = flightRecord.FlightDate;
            FlightTime           = flightRecord.FlightTime;
            IsRecordSetteled     = flightRecord.IsRecordSettled;
            IsRecordAutoSelected = flightRecord.IsRecordAutoSelected;
            AirportOrigin        = flightData.AirportOrigin;
            AirportDestination   = flightData.AirportDestination;
            DefaultSectorTime    = flightData.DefaultSectorTime;
            FlightDataConstant   = flightData.FlightDataConstant;
            IsFlightLocal        = flightData.IsFlightLocal;
            IsFlightCargo        = flightData.IsFlightCargo;
            FlightBonusCard      = flightData.FlightBonusCard;
            FlightInfo           = AirportOrigin + "/" + AirportDestination + " ," + DefaultSectorTime + "hrs" + " ," + FlightBonusCard + "Bonus";
            AircraftModel        = aircraftType.AircraftModel;
            EngineModel          = aircraftType.EngineModel;
            AircraftTypeSummary  = AircraftModel + " ," + EngineModel;
            AircraftTypeConstant = aircraftType.AircraftTypeConstant;
            GroupName            = currentGroup;
            FlightCompanyName    = flightRecord.FlightCompanyName;
            OriginTypeName       = flightRecord.OriginTypeName;
            EligibilityTypeName  = flightRecord.EligibilityTypeName;
            DestinationTypeName  = flightRecord.DestinationTypeName;
        }
        private List <Record> GetRecordList(string groupName)
        {
            RecordList = new List <Record>();
            var            flightRecordQuery = _flightSpannersData.GetFlightRecordByGroupName(groupName);
            Approval       approval;
            FlightData     flightData;
            AircraftType   aircraftType;
            ApprovalDetail approvalDetail;
            Spanner        spanner;
            bool           ApprovalNotNull = false;

            foreach (var flightRecord in flightRecordQuery)
            {
                flightData      = _flightSpannersData.GetFlightDataByFlightDataId(flightRecord.FlightDataId);
                aircraftType    = _flightSpannersData.GetAircraftTypeByAircraftTypeId(flightRecord.AircraftTypeId);
                ApprovalNotNull = flightRecord.ApprovalId.HasValue;
                if (ApprovalNotNull)
                {
                    approval       = _flightSpannersData.GetApprovalByApprovalId(flightRecord.ApprovalId.Value);
                    approvalDetail = _flightSpannersData.GetApprovalDetailByApprovalDetailId(approval.ApprovalDetailId);
                    spanner        = _flightSpannersData.GetSpannerByCode(approval.SpannerCode);

                    RecordList.Add(new Record
                    {
                        RecordId             = flightRecord.FlightRecordId,
                        RecordDate           = flightRecord.RecordDate,
                        RecordTime           = flightRecord.RecordTime,
                        FlightDate           = flightRecord.FlightDate,
                        FlightTime           = flightRecord.FlightTime,
                        IsRecordSetteled     = flightRecord.IsRecordSettled,
                        IsRecordAutoSelected = flightRecord.IsRecordAutoSelected,
                        AirportOrigin        = flightData.AirportOrigin,
                        AirportDestination   = flightData.AirportDestination,
                        DefaultSectorTime    = flightData.DefaultSectorTime,
                        FlightDataConstant   = flightData.FlightDataConstant,
                        IsFlightLocal        = flightData.IsFlightLocal,
                        IsFlightCargo        = flightData.IsFlightCargo,
                        FlightBonusCard      = flightData.FlightBonusCard,
                        AircraftModel        = aircraftType.AircraftModel,
                        EngineModel          = aircraftType.EngineModel,
                        AircraftTypeConstant = aircraftType.AircraftTypeConstant,
                        //SpannerCode = ApprovalNotNull ? spanner.SpannerCode : null,
                        SpannerCode         = spanner.SpannerCode,
                        SpannerName         = spanner.SpannerFName + " " + spanner.SpannerM1Name,
                        ApprovalRating      = approvalDetail.ApprovalRating,
                        ApprovalCategory    = approvalDetail.ApprovalCategory,
                        ApprovalConstant    = approvalDetail.ApprovalConstant,
                        GroupName           = groupName,
                        FlightCompanyName   = flightRecord.FlightCompanyName,
                        OriginTypeName      = flightRecord.OriginTypeName,
                        EligibilityTypeName = flightRecord.EligibilityTypeName,
                        DestinationTypeName = flightRecord.DestinationTypeName
                    });
                }
                else
                {
                    RecordList.Add(new Record
                    {
                        RecordId             = flightRecord.FlightRecordId,
                        RecordDate           = flightRecord.RecordDate,
                        RecordTime           = flightRecord.RecordTime,
                        FlightDate           = flightRecord.FlightDate,
                        FlightTime           = flightRecord.FlightTime,
                        IsRecordSetteled     = flightRecord.IsRecordSettled,
                        IsRecordAutoSelected = flightRecord.IsRecordAutoSelected,
                        AirportOrigin        = flightData.AirportOrigin,
                        AirportDestination   = flightData.AirportDestination,
                        DefaultSectorTime    = flightData.DefaultSectorTime,
                        FlightDataConstant   = flightData.FlightDataConstant,
                        IsFlightLocal        = flightData.IsFlightLocal,
                        IsFlightCargo        = flightData.IsFlightCargo,
                        FlightBonusCard      = flightData.FlightBonusCard,
                        AircraftModel        = aircraftType.AircraftModel,
                        EngineModel          = aircraftType.EngineModel,
                        AircraftTypeConstant = aircraftType.AircraftTypeConstant,
                        GroupName            = groupName,
                        FlightCompanyName    = flightRecord.FlightCompanyName,
                        OriginTypeName       = flightRecord.OriginTypeName,
                        EligibilityTypeName  = flightRecord.EligibilityTypeName,
                        DestinationTypeName  = flightRecord.DestinationTypeName
                    });
                }
            }
            return(RecordList);
        }