//Initialize SpannersDataDetailViewModel Properties public void SetSpannersDataDetailViewModelProperties(string spannerCode) { //var currentGroup = _httpContext.HttpContext.User.FindFirst(ClaimTypes.GroupSid).Value; Spanner spanner = _flightSpannersData.GetSpannerByCode(spannerCode); Qualification qualification = _flightSpannersData.GetQualificationByQualificationId(spanner.QualificationId); SpannerCode = spanner.SpannerCode; SpannerLicenseNo = spanner.SpannerLicenseNo; GroupName = spanner.GroupName; SpannerFName = spanner.SpannerFName; SpannerM1Name = spanner.SpannerM1Name; SpannerM2Name = spanner.SpannerM2Name; SpannerLName = spanner.SpannerLName; SpannerEmail = spanner.SpannerEmail; SpannerMobile1 = spanner.SpannerMobile1; SpannerMobile2 = spanner.SpannerMobile2; SpannerGender = spanner.SpannerGender; SpannerBirthday = spanner.SpannerBirthday; SpannerHireDate = spanner.SpannerHireDate; IsSpannerViewGroupData = spanner.IsSpannerViewGroupData; IsSpannerHasCar = spanner.IsSpannerHasCar; DepartmentName = spanner.DepartmentName; QualificationId = qualification.QualificationId; QualificationName = qualification.QualificationName; QualificationDegree = qualification.QualificationDegree; QualificationMajor = qualification.QualificationMajor; }
//Constructor injection public SpannerDataViewModel(IHttpContextAccessor httpContext, IFlightSpannersData flightSpannersData) { //IServiceProvider services = HttpContext.RequestServices; //[Optional] [FromServices] //var log = (IOrganizerData)services.GetService(typeof(IOrganizerData)); string code = httpContext.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; //Return the spanner based on the code var spanner = flightSpannersData.GetSpannerByCode(code); this.SpannerCode = spanner.SpannerCode; this.SpannerLicenseNo = spanner.SpannerLicenseNo; this.GroupName = spanner.GroupName; this.SpannerEmail = spanner.SpannerEmail; this.SpannerFName = spanner.SpannerFName; this.SpannerLName = spanner.SpannerLName; this.SpannerM1Name = spanner.SpannerM1Name; this.SpannerM2Name = spanner.SpannerM2Name; this.SpannerMobile1 = spanner.SpannerMobile1; this.SpannerMobile2 = spanner.SpannerMobile2; this.SpannerGender = spanner.SpannerGender; this.SpannerBirthday = spanner.SpannerBirthday; this.DepartmentName = spanner.DepartmentName; this.SpannerHireDate = spanner.SpannerHireDate; this.IsSpannerViewGroupData = spanner.IsSpannerViewGroupData; this.IsSpannerHasCar = spanner.IsSpannerHasCar; ////Get the Qualification of the spanner using GetQualificationSpanner(code) method this.SpannerQualification = flightSpannersData.GetQualificationOfSpanner(code); //Get the ApprovalList item of the model using GetApprovalSelectListItems(code) method this.ApprovalList = flightSpannersData.GetApprovalSelectListItems(code); }
//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 <DaysOfInActive> GetInActivePeriodList(string groupName) { InActivePeriodList = new List <DaysOfInActive>(); var inActiveDaysQuery = _flightSpannersData.GetInActivePeriodByGroupName(groupName); Spanner spanner; foreach (var inActiveDays in inActiveDaysQuery) { spanner = _flightSpannersData.GetSpannerByCode(inActiveDays.SpannerCode); InActivePeriodList.Add(new DaysOfInActive { SpannerCode = inActiveDays.SpannerCode, SpannerName = spanner.SpannerFName + " " + spanner.SpannerM1Name, InActivePeriodId = inActiveDays.InActivePeriodId, InActiveFromDate = inActiveDays.InActiveFromDate, InActiveToDate = inActiveDays.InActiveToDate }); } return(InActivePeriodList); }
public void SetFlightSummaryDetailViewModelProperties(string spannerCode) { GroupName = _httpContext.HttpContext.User.FindFirst(ClaimTypes.GroupSid).Value; //string spannerCode = _httpContext.HttpContext.Request.Query["SpannerCode"]; Spanner spanner = _flightSpannersData.GetSpannerByCode(spannerCode); SpannerCode = spannerCode; SpannerName = spanner.SpannerFName + " " + spanner.SpannerM1Name; DeservedFlights = _flightSpannersData.GetSpannerDeservedFlights(spannerCode); AllFlights = _flightSpannersData.GetFlightsAll(spannerCode); SpannerLicenseNo = spanner.SpannerLicenseNo; ShortFlights = _flightSpannersData.GetFlightsShort(spannerCode); LongFlights = _flightSpannersData.GetFlightsLong(spannerCode); ExtraFlights = _flightSpannersData.GetFlightsExtra(spannerCode); MultipleFlights = _flightSpannersData.GetFlightsMultiple(spannerCode); ApologyFlights = _flightSpannersData.GetFlightsApology(spannerCode); BonusFlights = _flightSpannersData.GetFlightsBonus(spannerCode); HolidayFlights = _flightSpannersData.GetFlightsHoliday(spannerCode); CurrentMonthFlights = _flightSpannersData.GetFlightsCurrentMonth(spannerCode); IsCurrentlyInActive = _flightSpannersData.IsCurrentlyInActive(spannerCode); Balance = _flightSpannersData.GetSpannerBalance(spannerCode); }
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); }