using System.Data; using Neo.Afx.ComponentModel; using System.Linq; using System.Collections.Generic; namespace Neo.LegitimateLicences.AccreditationIssueRequest.Models.Database { public class AccreditationIssueDatabase : Database { #region AccreditationIssueDatabase public AccreditationIssueDatabase() : base(new AccreditationIssueContext()) { } #endregion #region GetAccreditationIssueView public Vw_AccreditationIssueDetails GetAccreditationIssueView(long accreditationIssueDetailId, long userID) { var details = (from q in Context.Vw_AccreditationIssueDetails where q.AccreditationIssueDetailID == accreditationIssueDetailId select q).FirstOrDefault(); return details; } #endregion #region GetAccreditationIssueForm public AccreditationIssueDetail GetAccreditationIssueForm(long accreditationIssueDetailID, long userID) { var details = (from q in Context.AccreditationIssueDetails .Include("Accreditation") .Include("Accreditation.Member") where q.AccreditationIssueDetailID == accreditationIssueDetailID select q ).FirstOrDefault(); return details; } #endregion //#region GetLicenceIssueRequestTypeDocuments //public List GetLicenceIssueRequestTypeDocuments(short? LicenceIssueRequestTypeID, bool? isRenewal, bool isLtpsConversion, long workflowID, short provinceID) //{ // return Context.Fn_GetLicenceIssueRequestTypeDocuments(LicenceIssueRequestTypeID, isLtpsConversion, workflowID, -1, provinceID).ToList(); //} //#endregion //#region CreateApplication //public Vw_ApplicationDetails_Light CreateApplication(short LicenceIssueRequestTypeID, short sourceApplicationID, string applicantName, string applicantCell, short idTypeID, string idOrBusinessRegistrationNumber, string originatingLicenceNumbers, short? modeID, short? numberOfLicencesRequired, short divisionTypeID, short provinceID, short regionID, long userID) //{ // return Context.Pr_ApplicationCreate(LicenceIssueRequestTypeID, sourceApplicationID, applicantName, applicantCell, idTypeID, idOrBusinessRegistrationNumber, originatingLicenceNumbers, modeID, numberOfLicencesRequired, divisionTypeID, provinceID, regionID, userID).FirstOrDefault(); //} //#endregion //#region GetApplicationForm //public ApplicationDetail GetApplicationForm(long applicationDetailId, long userID) //{ // var details = (from q in Context.ApplicationDetails // .Include("Applicant") // .Include("Proxy") // .Include("Contract") // .Include("PreviousLicenceHolder") // .Include("NPTR") // where q.ApplicationDetailID == applicationDetailId // select q).FirstOrDefault(); // return details; //} //#endregion //#region GetApplicationCreateMemberLicences //public List GetApplicationCreateMemberLicences(long memberID, long userID) //{ // return Context.Pr_ApplicationCreateGetMemberLicences(memberID, userID).ToList(); //} //#endregion //#region GetApplicationLicences //public ApplicationDetail GetApplicationLicences(long applicationDetailId, long userID) //{ // var details = (from q in Context.ApplicationDetails // .Include("Applicant") // .Include("Licences") // .Include("Licences.PreviousVehicleDetail") // .Include("Licences.Routes") // .Include("Licences.Services") // .Include("Licences.VehicleDetail") // where q.ApplicationDetailID == applicationDetailId // select q).FirstOrDefault(); // return details; //} //#endregion //#region GetApplicationInspectionDetails //public ApplicationDetail GetApplicationInspectionDetails(long applicationDetailId, long userID) //{ // var details = (from q in Context.ApplicationDetails // .Include("InspectionDetails") // where q.ApplicationDetailID == applicationDetailId // select q).FirstOrDefault(); // return details; //} //#endregion //#region GetApplicationReferrals //public ApplicationDetail GetApplicationReferrals(long applicationDetailId, long userID) //{ // var details = (from q in Context.ApplicationDetails // .Include("Referrals") // .Include("Referrals.ReferralType") // where q.ApplicationDetailID == applicationDetailId // select q).FirstOrDefault(); // return details; //} //#endregion //#region GetLicenceVehicle //public ApplicationLicenceVehicleDetail GetLicenceVehicle(long applicationLicenceID, long userID) //{ // var details = (from q in Context.ApplicationLicenceVehicleDetails // where q.ApplicationLicenceID == applicationLicenceID // select q).FirstOrDefault(); // return details; //} //#endregion //#region GetLicenceServiceDetails //public ApplicationLicence GetLicenceServiceDetails(long applicationLicenceID, long userID) //{ // var details = (from q in Context.ApplicationLicences // .Include("Services") // where q.ApplicationLicenceID == applicationLicenceID // select q).FirstOrDefault(); // details.RemovedServices = new List(); // return details; //} //#endregion //#region AddApplicationLicenceRoute_Existing //public void AddApplicationLicenceRoute_Existing(long applicationLicenceID, long routeID, long userID) //{ // Context.Pr_ApplicationLicenceRoute_AddExisting(applicationLicenceID, routeID, userID); //} //#endregion //#region GetApplicationWorkflowStatusSummary //public List GetApplicationWorkflowStatusSummary(long applicationDetailId, long userID) //{ // return Context.Pr_Dashboard_ApplicationWorkflowStatusGet(applicationDetailId, userID).ToList(); //} //#endregion #region GetAccreditationIssuingWorkflowSummary public List GetAccreditationIssuingWorkflowSummary(long AccreditationIssueDetailID, long userID) { return Context.Pr_Dashboard_AccreditationIssuingWorkflowSummaryGet(AccreditationIssueDetailID, userID).ToList(); } #endregion #region GetAccreditationExceptions public List GetAccreditationExceptions(long accreditationID, long userID) { return (from q in Context.AccreditationExceptions where q.AccreditationID == accreditationID select q ).ToList(); } #endregion #region RecalculateAccreditationExceptions public void RecalculateAccreditationExceptions(long accreditationID) { Context.Pr_AccreditationExceptionsUpdate(accreditationID); } #endregion ////#region GetLicenceIssueRequestDetails ////public Vw_LicenceIssueRequestDetails GetLicenceIssueRequestDetails(long LicenceIssueRequestDetailId) ////{ //// return (from q in Context.Vw_LicenceIssueRequestDetails where q.LicenceIssueRequestDetailID == LicenceIssueRequestDetailId select q).FirstOrDefault(); ////} ////#endregion ////#region GetLicenceIssueRequest ////public LicenceIssueRequestDetail GetLicenceIssueRequest(long LicenceIssueRequestDetailId, long userID) ////{ //// if (LicenceIssueRequestDetailId == -1) //// { //// var ranks = new Collection(); //// ranks.Add(new ApplicationRankDetail //// { //// IsDefaultRank = true //// }); //// return new LicenceIssueRequestDetail() //// { //// LicenceIssueRequestDetailID = LicenceIssueRequestDetailId, //// LicenceIssueRequestTypeID = (short)RequestTypeEnum.NewOperatingLicence, //// ProvinceID = (short)Common.ProvinceEnum.KwaZuluNatal, //// Applicant = new ApplicationApplicantDetail(), //// Mode = new ApplicationModeDetail(), //// Proxy = new ApplicationProxyDetail(), //// Routes = new Collection(), //// Services = new Collection(), //// Vehicle = new ApplicationVehicleDetail(), //// Documents = new Collection(), //// Contract = new ApplicationContractDetail(), //// Ranks = ranks, //// ExistingLicence = new ApplicationExistingLicence(), //// ExistingLicenceHolder = new ApplicationExistingLicenceHolder(), //// ExistingVehicle = new ApplicationExistingVehicleDetail(), //// Objections = new Collection(), //// ApplicationVehicleDetailsInBulk = new Collection(), //// CreatedByID = userID, //// CreatedDate = DateTime.Now, //// UpdatedByID = userID, //// UpdatedDate = DateTime.Now //// }; //// } //// var details = (from q in Context.LicenceIssueRequestDetails.Include("Applicant").Include("Mode").Include("Proxy").Include("Routes").Include("Services").Include("Vehicle").Include("ApplicationVehicleDetailsInBulk").Include("ExistingVehicle").Include("Documents").Include("Documents.DocumentType").Include("Contract").Include("ReceiptDetails").Include("Ranks").Include("ExistingLicenceHolder").Include("ExistingLicence").Include("Objections").Include("Objections.CreatedBy").Include("LicenceIssueRequestAdjudicationDecisions").Include("LicenceIssueRequestAdjudicationDecisions.AdjudicationDecision").Include("LicenceIssueRequestAdjudicationDecisions.AdjudicatedBy").Include("LicenceIssueRequestAdjudicationDecisions.LicenceDuration") //// where q.LicenceIssueRequestDetailID == LicenceIssueRequestDetailId //// select q).FirstOrDefault(); //// if (details.GazetteDetailID.HasValue) //// { //// details.GazetteDetail = (from q in Context.GazetteDetails where q.GazetteDetailID == details.GazetteDetailID.Value select q).FirstOrDefault(); //// } //// return details; ////} ////#endregion ////#region GetApplicationsRequestTypes ////public IEnumerable GetApplicationsRequestTypes() ////{ //// return Context.LicenceIssueRequestTypes.Where(a => !a.IsCancelled.Value).ToList(); ////} ////#endregion ////#region GetLicenceIssueRequestType ////public LicenceIssueRequestType GetLicenceIssueRequestType(short LicenceIssueRequestTypeID, bool includeAll) ////{ //// var requestType = Context.LicenceIssueRequestTypes.Where(a => a.LicenceIssueRequestTypeID == LicenceIssueRequestTypeID).FirstOrDefault(); //// if (includeAll) //// { //// requestType.LicenceIssueRequestTypeDocuments = Context.LicenceIssueRequestTypeDocuments.Include("DocumentType").Where(a => a.LicenceIssueRequestType.LicenceIssueRequestTypeID == LicenceIssueRequestTypeID && !a.IsCancelled).ToList(); //// } //// return requestType; ////} ////#endregion ////#region GetLicenceIssueRequestObjections ////public IEnumerable GetLicenceIssueRequestObjections(long LicenceIssueRequestDetailID) ////{ //// return Context.LicenceIssueRequestObjections.Include("CreatedBy").Where(a => a.LicenceIssueRequestDetailID == LicenceIssueRequestDetailID).ToList(); ////} ////#endregion ////#region SaveLicenceIssueRequestObjection ////public IEnumerable SaveLicenceIssueRequestObjection(LicenceIssueRequestObjection objection, long userID) ////{ //// Context.Pr_LicenceIssueRequestObjectionUpsert(objection.LicenceIssueRequestObjectionID, //// objection.LicenceIssueRequestDetailID, //// objection.Objector, //// objection.Objection, //// objection.ObjectionDate, //// objection.PostalAddress, //// objection.PostalAddressCode, //// objection.TelPhone, //// objection.TelCell, //// objection.TelFax, //// objection.Email, //// objection.ObjectionDocumentID, //// userID); //// return GetLicenceIssueRequestObjections(objection.LicenceIssueRequestDetailID); ////} ////#endregion ////#region GetVerifiedRoute ////public Route GetVerifiedRoute(int routeId) ////{ //// return Context.Routes.Where(a => a.RouteID == routeId).FirstOrDefault(); ////} ////#endregion #region AddPrecheckDetailToLicenceIssueRequestDetail /// /// Prepopulate object with values from source system /// /// /// /// //////public LicenceIssueRequestDetail AddPrecheckDetailToLicenceIssueRequestDetail(LicenceIssueRequestDetail value, long userID) //////{ ////// var legitimateDb = new LegitimateDatabase(); ////// #region add relevant Precheck details ////// var precheckDetail = Context.PrecheckDetails.Where(a => a.PrecheckDetailID == data.PrecheckDetailID).FirstOrDefault(); ////// if (precheckDetail != null) ////// { ////// var precheckOlPermitNumber = precheckDetail.OlPermitNumber; ////// //strip out the version number if found ////// if (precheckOlPermitNumber.Contains("/")) ////// { ////// precheckOlPermitNumber = precheckOlPermitNumber.Substring(0, precheckOlPermitNumber.LastIndexOf("/")); ////// } ////// data.IsRenewal = precheckDetail.IsRenewal; ////// data.IsLateRenewal = precheckDetail.IsLateRenewal; ////// data.IsLtpsConversion = precheckDetail.IsLtpsConversion; ////// #region New Operating Licence ////// if (data.LicenceIssueRequestTypeID == (short)Common.LicenceIssueRequestTypeEnum.NewOperatingLicence) ////// { ////// if (!String.IsNullOrWhiteSpace(precheckDetail.ApplicantName)) ////// { ////// var names = precheckDetail.ApplicantName.Split(' '); ////// data.Applicant.FirstNames = names[0]; ////// if (names.Length > 1) ////// { ////// data.Applicant.SurnameOrCompanyName = names[1]; ////// } ////// } ////// if (!String.IsNullOrWhiteSpace(precheckDetail.IDNumber)) ////// { ////// var member = legitimateDb.Purification_FindMember(precheckDetail.IDNumber, userID); ////// var verifiedMember = legitimateDb.GetVerifiedMember(precheckDetail.IDNumber); ////// if (member != null) ////// { ////// #region Populate applicant details based on verified data ////// data.Applicant.Email = member.Email; ////// data.Applicant.FirstNames = member.FirstNames; ////// data.Applicant.IDNumberOrBusinessRegistrationNo = member.IDNumber; ////// data.Applicant.SARSIncomeTaxNumber = member.SARSIncomeTaxNumber; ////// data.Applicant.SARSReasonIfNoTaxNumber = member.SARSReasonIfNoTaxNumber; ////// data.Applicant.SurnameOrCompanyName = member.SurnameOrCompanyName; ////// data.Applicant.TelCell = member.TelCell; ////// data.Applicant.TelFax = member.TelFax; ////// data.Applicant.TelPhone = member.TelPhone; ////// data.Applicant.PhysicalAddress = member.PhysicalAddress; ////// data.Applicant.PhysicalAddressCode = member.PhysicalAddressCode; ////// data.Applicant.PostalAddress = member.PostalAddress; ////// data.Applicant.PostalAddressCode = member.PostalAddressCode; ////// data.Applicant.TradeName = member.TradeName; ////// data.Applicant.BusinessTypeID = member.BusinessTypeID; ////// if (verifiedMember != null) ////// { ////// data.Applicant.VerifiedMemberID = verifiedMember.MemberID; ////// data.Applicant.IDTypeID = verifiedMember.IDTypeID; ////// data.Applicant.IDTypeDescription = verifiedMember.IDTypeDescription; ////// } ////// #endregion ////// } ////// else { ////// data.Applicant.IDNumberOrBusinessRegistrationNo = precheckDetail.IDNumber; ////// } ////// } ////// if (!String.IsNullOrWhiteSpace(precheckDetail.ChassisNumber)) ////// { ////// if (data.Vehicle != null) ////// { ////// data.Vehicle.VIN = precheckDetail.ChassisNumber; ////// } ////// } ////// if (!String.IsNullOrWhiteSpace(precheckDetail.VehicleRegistrationNumber)) ////// { ////// if (data.Vehicle != null) ////// { ////// data.Vehicle.VehicleRegistrationNumber = precheckDetail.VehicleRegistrationNumber; ////// } ////// } ////// if (precheckDetail.AssociationID.HasValue) ////// { ////// var associationRoutes = legitimateDb.GetVerifiedAssociationRoutes(precheckDetail.AssociationID.Value); ////// foreach (var route in associationRoutes) ////// { ////// var origin = (route.OriginPlaceID.HasValue) ? legitimateDb.GetVerifiedPlace(route.OriginPlaceID.Value).Description : ""; ////// var destination = (route.DestinationPlaceID.HasValue) ? legitimateDb.GetVerifiedPlace(route.DestinationPlaceID.Value).Description : ""; ////// var routeName = route.RouteName; ////// if (!String.IsNullOrWhiteSpace(routeName)) ////// { ////// short appRouteStatusId = 2; //default to awaiting verification ////// if (route.RouteStatusID == 1) //active ////// { ////// appRouteStatusId = 3; //verfied ////// } ////// data.Routes.Add(new ApplicationRouteDetail() ////// { ////// ApplicationRouteDetailStatusID = appRouteStatusId, ////// BoardRouteNumber = route.BoardRouteNumber, ////// NationalRouteNumber = route.NationalRouteNumber, ////// RouteDescription = route.Description, ////// RouteLength = route.RouteLength, ////// VerifiedRouteID = route.RouteID, ////// RouteDestination = destination, ////// RouteOrigin = origin, ////// RouteChangeTypeID = (short)RouteChangeTypeEnum.ExistingRouteOnLicence ////// }); ////// } ////// } ////// } ////// #region create vehicle rows if bulk vehicle application ////// data.IsBulkVehicleApplication = (precheckDetail != null && precheckDetail.NumberOfVehiclesRequired.HasValue && precheckDetail.NumberOfVehiclesRequired.Value > 1); ////// data.ApplicationVehicleDetailsInBulk = new List(); ////// if (data.IsBulkVehicleApplication) ////// { ////// for (var x = 1; x <= precheckDetail.NumberOfVehiclesRequired.Value; x++) ////// { ////// data.ApplicationVehicleDetailsInBulk.Add(new ApplicationVehicleDetailsInBulk() { VehicleNumber = x }); ////// } ////// } ////// #endregion ////// data.Applicant.VerifiedAssociationID = precheckDetail.AssociationID; ////// data.ExistingLicence.OperatingLicenceNumber = precheckDetail.OlPermitNumber; ////// } ////// #endregion ////// short precheckModeID = -1; ////// var applicant = new XElement("applicant"); ////// var applicantLicence = new XElement("licence"); ////// var applicantVehicle = new XElement("vehicle"); ////// var foundApplication = false; ////// if (precheckDetail.ModeID.HasValue) ////// { ////// precheckModeID = precheckDetail.ModeID.Value; ////// } ////// Fn_GetSourceApplicationRecordsFromSourceSystem_Result sourceSystemData = null; ////// if (!string.IsNullOrEmpty(precheckDetail.OlPermitNumber)) ////// { ////// sourceSystemData = GetSourceApplicationFromSourceSystem(precheckDetail.OlPermitNumber, precheckDetail.SourceApplicationID, precheckModeID, true, false); ////// } ////// if (sourceSystemData != null) ////// { ////// foundApplication = true; ////// applicant = XElement.Parse(sourceSystemData.ApplicantXML); ////// applicantLicence = XElement.Parse(sourceSystemData.LicenceXML); ////// applicantVehicle = XElement.Parse(sourceSystemData.VehicleXML); ////// } ////// if (foundApplication) ////// { ////// if (data.SourceApplicationID == (short)Common.SourceApplicationEnum.Legitimate) ////// { ////// var licenceId = (long)applicantLicence.Element("licenceid"); ////// var licence = legitimateDb.GetVerifiedLicence(licenceId); //if the source is a legitimate licence the data in the Db is used, as opposed to the xml ////// var serviceDetails = legitimateDb.GetVerifiedLicenceServiceDetails(licenceId); ////// var routes = legitimateDb.GetVerifiedLicenceRoutes(licenceId); ////// #region Applicant Details ////// if (LicenceIssueRequestHelper.IsTransferType(data.LicenceIssueRequestTypeID)) ////// { ////// if (licence.Member != null) ////// { ////// data.ExistingLicenceHolder.Email = licence.Member.Email; ////// data.ExistingLicenceHolder.FirstNames = licence.Member.FirstNames; ////// data.ExistingLicenceHolder.IDNumberOrBusinessRegistrationNo = licence.Member.IDNumberOrBusinessRegistrationNo; ////// data.ExistingLicenceHolder.SARSIncomeTaxNumber = licence.Member.SARSIncomeTaxNumber; ////// data.ExistingLicenceHolder.SurnameOrCompanyName = licence.Member.SurnameOrCompanyName; ////// data.ExistingLicenceHolder.TelCell = licence.Member.TelCell; ////// data.ExistingLicenceHolder.TelFax = licence.Member.TelFax; ////// data.ExistingLicenceHolder.TelPhone = licence.Member.TelPhone; ////// data.ExistingLicenceHolder.IDTypeID = licence.Member.IDTypeID; ////// data.ExistingLicenceHolder.IDTypeDescription = licence.Member.IDTypeDescription; ////// data.ExistingLicenceHolder.PhysicalAddress = licence.Member.PhysicalAddress; ////// data.ExistingLicenceHolder.PhysicalAddressCode = licence.Member.PhysicalAddressCode; ////// data.ExistingLicenceHolder.PostalAddress = licence.Member.PostalAddress; ////// data.ExistingLicenceHolder.PostalAddressCode = licence.Member.PostalAddressCode; ////// } ////// //also set the new applicant's association to the original member's association ////// data.Applicant.VerifiedAssociationID = precheckDetail.AssociationID; ////// } ////// else ////// { ////// if (licence.Member != null) ////// { ////// data.Applicant.Email = licence.Member.Email; ////// data.Applicant.FirstNames = licence.Member.FirstNames; ////// data.Applicant.IDNumberOrBusinessRegistrationNo = licence.Member.IDNumberOrBusinessRegistrationNo; ////// data.Applicant.SARSIncomeTaxNumber = licence.Member.SARSIncomeTaxNumber; ////// data.Applicant.SurnameOrCompanyName = licence.Member.SurnameOrCompanyName; ////// data.Applicant.TelCell = licence.Member.TelCell; ////// data.Applicant.TelFax = licence.Member.TelFax; ////// data.Applicant.TelPhone = licence.Member.TelPhone; ////// data.Applicant.IDTypeID = licence.Member.IDTypeID; ////// data.Applicant.IDTypeDescription = licence.Member.IDTypeDescription; ////// data.Applicant.PhysicalAddress = licence.Member.PhysicalAddress; ////// data.Applicant.PhysicalAddressCode = licence.Member.PhysicalAddressCode; ////// data.Applicant.PostalAddress = licence.Member.PostalAddress; ////// data.Applicant.PostalAddressCode = licence.Member.PostalAddressCode; ////// data.Applicant.VerifiedMemberID = licence.Member.MemberID; ////// } ////// data.Applicant.VerifiedAssociationID = precheckDetail.AssociationID; ////// } ////// #endregion ////// #region licence detail ////// data.ExistingLicence.OperatingLicenceNumber = licence.OperatingLicenceNumber; ////// data.ExistingLicence.OperatingLicenceIssueDate = licence.DateOfIssue; ////// data.ExistingLicence.OperatingLicenceIssuingBoard = "KZN Public Transport Licensing Board"; ////// data.ExistingLicence.OperatingLicenceExpiryDate = licence.DateOfExpiry; ////// #region vehicle ////// if (!LicenceIssueRequestHelper.IsCovtype(data.LicenceIssueRequestTypeID) && data.LicenceIssueRequestTypeID != (short)Neo.LegitimateLicences.Common.LicenceIssueRequestTypeEnum.TemporaryReplacements) ////// { ////// var vehicle = new ApplicationVehicleDetail() ////// { ////// IsStillToBeAcquired = false, ////// VehicleMakeID = (licence.Vehicle != null && licence.Vehicle.VehicleMakeID.HasValue) ? licence.Vehicle.VehicleMakeID : null, ////// VehicleMakeDescription = (licence.Vehicle != null && licence.Vehicle.VehicleMake != null) ? licence.Vehicle.VehicleMake.Description : null, ////// VehicleTypeID = (licence.Vehicle != null && licence.Vehicle.VehicleTypeID.HasValue) ? licence.Vehicle.VehicleTypeID : null, ////// VIN = (licence.Vehicle != null) ? licence.Vehicle.VIN : null, ////// EngineNumber = (licence.Vehicle != null) ? licence.Vehicle.EngineNumber : null, ////// YearOfManufacture = (licence.Vehicle != null) ? licence.Vehicle.YearOfManufacture : null, ////// VehicleRegistrationNumber = (licence.Vehicle != null) ? licence.Vehicle.RegistrationNumber : null, ////// SeatedCapacity = (licence.Vehicle != null && licence.Vehicle.SeatedCapacity.HasValue) ? licence.Vehicle.SeatedCapacity.ToInt16() : null, ////// StandingCapacity = (licence.Vehicle != null && licence.Vehicle.StandingCapacity.HasValue) ? licence.Vehicle.StandingCapacity.ToInt16() : null, ////// GrossMass = (licence.Vehicle != null && licence.Vehicle.GrossMass.HasValue) ? licence.Vehicle.GrossMass.ToInt64() : null, ////// VerifiedVehicleID = (licence.Vehicle != null) ? licence.Vehicle.VehicleID : (long?)null, ////// CarryingCapacityID = (licence.Vehicle != null && licence.Vehicle.CarryingCapacityID.HasValue) ? licence.Vehicle.CarryingCapacityID : null ////// }; ////// data.Vehicle = vehicle; ////// } ////// else ////// { ////// var vehicle = new ApplicationExistingVehicleDetail() ////// { ////// IsStillToBeAcquired = false, ////// VehicleMakeID = (licence.Vehicle != null && licence.Vehicle.VehicleMakeID.HasValue) ? licence.Vehicle.VehicleMakeID : null, ////// VehicleMakeDescription = (licence.Vehicle != null && licence.Vehicle.VehicleMake != null) ? licence.Vehicle.VehicleMake.Description : null, ////// VehicleTypeID = (licence.Vehicle != null && licence.Vehicle.VehicleTypeID.HasValue) ? licence.Vehicle.VehicleTypeID : null, ////// VIN = (licence.Vehicle != null) ? licence.Vehicle.VIN : null, ////// EngineNumber = (licence.Vehicle != null) ? licence.Vehicle.EngineNumber : null, ////// YearOfManufacture = (licence.Vehicle != null) ? licence.Vehicle.YearOfManufacture : null, ////// VehicleRegistrationNumber = (licence.Vehicle != null) ? licence.Vehicle.RegistrationNumber : null, ////// SeatedCapacity = (licence.Vehicle != null && licence.Vehicle.SeatedCapacity.HasValue) ? licence.Vehicle.SeatedCapacity.ToInt16() : null, ////// StandingCapacity = (licence.Vehicle != null && licence.Vehicle.StandingCapacity.HasValue) ? licence.Vehicle.StandingCapacity.ToInt16() : null, ////// GrossMass = (licence.Vehicle != null && licence.Vehicle.GrossMass.HasValue) ? licence.Vehicle.GrossMass.ToInt64() : null, ////// VerifiedVehicleID = (licence.Vehicle != null) ? licence.Vehicle.VehicleID : (long?)null, ////// CarryingCapacityID = (licence.Vehicle != null && licence.Vehicle.CarryingCapacityID.HasValue) ? licence.Vehicle.CarryingCapacityID : null ////// }; ////// data.ExistingVehicle = vehicle; ////// } ////// #endregion ////// #region service types ////// foreach (var serviceType in serviceDetails) ////// { ////// //ensure only 'other' service type is kept if mode is other ////// if (licence.ModeID == (short)Neo.LegitimateLicences.Common.ModeEnum.Other) ////// { ////// if (serviceType.ServiceTypeID == (short)Neo.LegitimateLicences.Common.ServiceTypeEnum.Other) ////// { ////// data.Services.Add(new ApplicationServiceDetail() ////// { ////// ServiceTypeID = serviceType.ServiceTypeID, ////// ServiceTypeDescription = serviceType.ServiceTypeDescription ////// }); ////// } ////// } ////// else { ////// data.Services.Add(new ApplicationServiceDetail() ////// { ////// ServiceTypeID = serviceType.ServiceTypeID, ////// ServiceTypeDescription = serviceType.ServiceTypeDescription ////// }); ////// } ////// } ////// #endregion ////// #region Mode ////// var mode = legitimateDb.GetMode(licence.ModeID); ////// if (mode != null) ////// { ////// data.Mode.ModeID = licence.ModeID; ////// data.Mode.ModeDescription = mode.Description; ////// } ////// #endregion ////// #region routes ////// if (data.LicenceIssueRequestTypeID != (short)Neo.LegitimateLicences.Common.LicenceIssueRequestTypeEnum.TemporarySpecialLicence) ////// { ////// foreach (var route in routes) ////// { ////// var origin = (route.OriginPlaceID.HasValue) ? legitimateDb.GetVerifiedPlace(route.OriginPlaceID.Value).Description : ""; ////// var destination = (route.DestinationPlaceID.HasValue) ? legitimateDb.GetVerifiedPlace(route.DestinationPlaceID.Value).Description : ""; ////// var routeName = route.RouteName; ////// if (!String.IsNullOrWhiteSpace(routeName)) ////// { ////// short appRouteStatusId = 2; //default to awaiting verification ////// if (route.RouteStatusID == 1) //active ////// { ////// appRouteStatusId = 3; //verfied ////// } ////// data.Routes.Add(new ApplicationRouteDetail() ////// { ////// ApplicationRouteDetailStatusID = appRouteStatusId, ////// BoardRouteNumber = route.BoardRouteNumber, ////// NationalRouteNumber = route.NationalRouteNumber, ////// RouteDescription = route.Description, ////// RouteLength = route.RouteLength, ////// VerifiedRouteID = route.RouteID, ////// RouteDestination = destination, ////// RouteOrigin = origin, ////// RouteChangeTypeID = (short)RouteChangeTypeEnum.ExistingRouteOnLicence ////// }); ////// } ////// } ////// } ////// #endregion ////// #endregion ////// } ////// else ////// { ////// if (LicenceIssueRequestHelper.IsTransferType(data.LicenceIssueRequestTypeID)) ////// { ////// #region Existing Member details ////// if (applicant != null) ////// { ////// data.ExistingLicenceHolder.Email = (string)applicant.Element("emailaddress"); ////// data.ExistingLicenceHolder.FirstNames = (string)applicant.Element("firstname"); ////// data.ExistingLicenceHolder.IDNumberOrBusinessRegistrationNo = (string)applicant.Element("idnumber"); ////// data.ExistingLicenceHolder.SARSIncomeTaxNumber = (string)applicant.Element("incometaxnumber"); ////// data.ExistingLicenceHolder.SurnameOrCompanyName = (string)applicant.Element("lastname"); ////// data.ExistingLicenceHolder.TelCell = (string)applicant.Element("cellnumber"); ////// data.ExistingLicenceHolder.TelFax = (string)applicant.Element("faxnumber"); ////// data.ExistingLicenceHolder.TelPhone = (string)applicant.Element("telephonenumber"); ////// if (applicant.Element("idtypeid") != null) ////// { ////// short idType = 0; ////// if (!short.TryParse(applicant.Element("idtypeid").ToString(), out idType)) ////// { ////// idType = 1; ////// } ////// var idTypeRecord = Context.IDTypes.Where(a => a.OlasID == idType).FirstOrDefault(); ////// if (idTypeRecord != null) ////// { ////// data.ExistingLicenceHolder.IDTypeID = idTypeRecord.IDTypeID; ////// data.ExistingLicenceHolder.IDTypeDescription = idTypeRecord.Description; ////// } ////// else ////// { ////// data.ExistingLicenceHolder.IDTypeDescription = (string)applicant.Element("idtypedescription"); ////// } ////// } ////// if (applicant.Element("physicaladdress") != null) ////// { ////// var physicalAddress = (string)applicant.Element("physicaladdress").Element("addressline1") + "\r\n" + ////// (string)applicant.Element("physicaladdress").Element("addressline2") + "\r\n" + ////// (string)applicant.Element("physicaladdress").Element("addressline3") + "\r\n" + ////// (string)applicant.Element("physicaladdress").Element("province"); ////// data.ExistingLicenceHolder.PhysicalAddress = (string.IsNullOrWhiteSpace(physicalAddress)) ? "" : physicalAddress; ////// data.ExistingLicenceHolder.PhysicalAddressCode = (string)applicant.Element("physicaladdress").Element("pocode"); ////// } ////// if (applicant.Element("postaladdress") != null) ////// { ////// var postalAddress = (string)applicant.Element("postaladdress").Element("addressline1") + "\r\n" + ////// (string)applicant.Element("postaladdress").Element("addressline2") + "\r\n" + ////// (string)applicant.Element("postaladdress").Element("addressline3") + "\r\n" + ////// (string)applicant.Element("postaladdress").Element("province"); ////// data.ExistingLicenceHolder.PostalAddress = (string.IsNullOrWhiteSpace(postalAddress)) ? "" : postalAddress; ////// data.ExistingLicenceHolder.PostalAddressCode = (string)applicant.Element("postaladdress").Element("pocode"); ////// } ////// } ////// //also set the new applicant's association to the original member's association ////// data.Applicant.VerifiedAssociationID = precheckDetail.AssociationID; ////// #endregion ////// } ////// else ////// { ////// var idNumber = (string)applicant.Element("idnumber"); ////// var verifiedmember = legitimateDb.GetVerifiedMember(idNumber); ////// if (verifiedmember != null) ////// { ////// #region Populate applicant details based on verified data ////// data.Applicant.Email = verifiedmember.Email; ////// data.Applicant.FirstNames = verifiedmember.FirstNames; ////// data.Applicant.IDNumberOrBusinessRegistrationNo = verifiedmember.IDNumberOrBusinessRegistrationNo; ////// data.Applicant.SARSIncomeTaxNumber = verifiedmember.SARSIncomeTaxNumber; ////// data.Applicant.SurnameOrCompanyName = verifiedmember.SurnameOrCompanyName; ////// data.Applicant.TelCell = verifiedmember.TelCell; ////// data.Applicant.TelFax = verifiedmember.TelFax; ////// data.Applicant.TelPhone = verifiedmember.TelPhone; ////// data.Applicant.IDTypeID = verifiedmember.IDTypeID; ////// data.Applicant.IDTypeDescription = verifiedmember.IDTypeDescription; ////// data.Applicant.PhysicalAddress = verifiedmember.PhysicalAddress; ////// data.Applicant.PhysicalAddressCode = verifiedmember.PhysicalAddressCode; ////// data.Applicant.PostalAddress = verifiedmember.PostalAddress; ////// data.Applicant.PostalAddressCode = verifiedmember.PostalAddressCode; ////// data.Applicant.VerifiedMemberID = verifiedmember.MemberID; ////// data.Applicant.VerifiedAssociationID = precheckDetail.AssociationID; ////// #endregion ////// } ////// else { ////// #region Applicant Details ////// if (applicant != null) ////// { ////// data.Applicant.Email = (string)applicant.Element("emailaddress"); ////// data.Applicant.FirstNames = (string)applicant.Element("firstname"); ////// data.Applicant.IDNumberOrBusinessRegistrationNo = (string)applicant.Element("idnumber"); ////// data.Applicant.SARSIncomeTaxNumber = (string)applicant.Element("incometaxnumber"); ////// data.Applicant.SurnameOrCompanyName = (string)applicant.Element("lastname"); ////// data.Applicant.TelCell = (string)applicant.Element("cellnumber"); ////// data.Applicant.TelFax = (string)applicant.Element("faxnumber"); ////// data.Applicant.TelPhone = (string)applicant.Element("telephonenumber"); ////// if (applicant.Element("idtypeid") != null) ////// { ////// short idType = 0; ////// if (!short.TryParse(applicant.Element("idtypeid").ToString(), out idType)) ////// { ////// idType = 1; ////// } ////// var idTypeRecord = Context.IDTypes.Where(a => a.OlasID == idType).FirstOrDefault(); ////// if (idTypeRecord != null) ////// { ////// data.Applicant.IDTypeID = idTypeRecord.IDTypeID; ////// data.Applicant.IDTypeDescription = idTypeRecord.Description; ////// } ////// else ////// { ////// data.Applicant.IDTypeDescription = (string)applicant.Element("idtypedescription"); ////// } ////// } ////// if (applicant.Element("businesstypeid") != null) ////// { ////// var businessType = (short)applicant.Element("businesstypeid"); ////// var businessTypeRecord = Context.BusinessTypes.Where(a => a.OlasID == businessType).FirstOrDefault(); ////// if (businessTypeRecord != null) ////// { ////// data.Applicant.BusinessTypeID = businessTypeRecord.BusinessTypeID; ////// } ////// } ////// if (applicant.Element("physicaladdress") != null) ////// { ////// var physicalAddress = (string)applicant.Element("physicaladdress").Element("addressline1") + "\r\n" + ////// (string)applicant.Element("physicaladdress").Element("addressline2") + "\r\n" + ////// (string)applicant.Element("physicaladdress").Element("addressline3") + "\r\n" + ////// (string)applicant.Element("physicaladdress").Element("province"); ////// data.Applicant.PhysicalAddress = (string.IsNullOrWhiteSpace(physicalAddress)) ? "" : physicalAddress; ////// data.Applicant.PhysicalAddressCode = (string)applicant.Element("physicaladdress").Element("pocode"); ////// } ////// if (applicant.Element("postaladdress") != null) ////// { ////// var postalAddress = (string)applicant.Element("postaladdress").Element("addressline1") + "\r\n" + ////// (string)applicant.Element("postaladdress").Element("addressline2") + "\r\n" + ////// (string)applicant.Element("postaladdress").Element("addressline3") + "\r\n" + ////// (string)applicant.Element("postaladdress").Element("province"); ////// data.Applicant.PostalAddress = (string.IsNullOrWhiteSpace(postalAddress)) ? "" : postalAddress; ////// data.Applicant.PostalAddressCode = (string)applicant.Element("postaladdress").Element("pocode"); ////// } ////// } ////// #region create verified member record from source data ////// if (data.Applicant != null && !String.IsNullOrWhiteSpace(data.Applicant.IDNumberOrBusinessRegistrationNo)) ////// { ////// long? olasID = null; ////// long? ltpsID = null; ////// if (data.SourceApplicationID == (short)Common.SourceApplicationEnum.NTLIS) ////// { ////// olasID = (long)applicant.Element("personid"); ////// } ////// data.Applicant.VerifiedMemberID = Context.Pr_MemberUpsert(-1, null, null, data.Applicant.SurnameOrCompanyName, data.Applicant.FirstNames, data.Applicant.IDTypeID, data.Applicant.IDTypeDescription, data.Applicant.IDNumberOrBusinessRegistrationNo, data.Applicant.PostalAddress, data.Applicant.PostalAddressCode, data.Applicant.PhysicalAddress, data.Applicant.PhysicalAddressCode, data.Applicant.TelPhone, data.Applicant.TelCell, data.Applicant.TelFax, data.Applicant.Email, data.Applicant.SARSIncomeTaxNumber, data.Applicant.SARSReasonIfNoTaxNumber, data.Applicant.TradeName,data.Applicant.BusinessTypeID, olasID, ltpsID, userID, "Create record based on imported data", false).FirstOrDefault().Value.ToInt64(); ////// } ////// #endregion ////// //also set the new applicant's association to the original member's association ////// data.Applicant.VerifiedAssociationID = precheckDetail.AssociationID; ////// #endregion ////// } ////// } ////// #region licence detail ////// data.ExistingLicence.OperatingLicenceNumber = (string)applicantLicence.Element("licencenumber"); ////// data.ExistingLicence.OperatingLicenceIssueDate = (applicantLicence.Element("startdate") != null) ? applicantLicence.Element("startdate").Value.ToDateTime() : null; ////// data.ExistingLicence.OperatingLicenceIssuingBoard = "KZN Public Transport Licensing Board"; ////// if ((string)applicantLicence.Element("indefinite") != "1") ////// { ////// data.ExistingLicence.OperatingLicenceExpiryDate = (applicantLicence.Element("enddate") != null) ? applicantLicence.Element("enddate").Value.ToDateTime() : DateTime.Now; ////// } ////// else ////// { ////// data.ExistingLicence.OperatingLicenceExpiryDate = DateTime.Now; ////// } ////// #region vehicle ////// if (!LicenceIssueRequestHelper.IsCovtype(data.LicenceIssueRequestTypeID) && data.LicenceIssueRequestTypeID != (short)Neo.LegitimateLicences.Common.LicenceIssueRequestTypeEnum.TemporaryReplacements) ////// { ////// var vehicle = new ApplicationVehicleDetail() ////// { ////// IsStillToBeAcquired = false, ////// VehicleMakeDescription = (applicantVehicle != null && applicantVehicle.Element("vehiclemake") != null) ? (string)applicantVehicle.Element("vehiclemake") : "", ////// VehicleRegistrationNumber = (applicantVehicle != null && applicantVehicle.Element("registrationnumber") != null) ? (string)applicantVehicle.Element("registrationnumber") : "", ////// VIN = (applicantVehicle != null && applicantVehicle.Element("chassisnumber") != null) ? (string)applicantVehicle.Element("chassisnumber") : "", ////// EngineNumber = (applicantVehicle != null && applicantVehicle.Element("enginenumber") != null) ? (string)applicantVehicle.Element("enginenumber") : "", ////// SeatedCapacity = (applicantVehicle != null && applicantVehicle.Element("seatingcapacity") != null) ? applicantVehicle.Element("seatingcapacity").Value.ToInt16() : null, ////// GrossMass = (applicantVehicle != null && applicantVehicle.Element("grossmass") != null) ? applicantVehicle.Element("grossmass").Value.ToInt64() : null, ////// RoadworthyCertificateNumber = (applicantVehicle != null && applicantVehicle.Element("cofreferencenumber") != null) ? applicantVehicle.Element("cofreferencenumber").Value.ToString() : "", ////// RoadworthyExpiryDate = (applicantVehicle != null && applicantVehicle.Element("cofexpiry") != null) ? applicantVehicle.Element("cofexpiry").Value.ToDateTime() : null ////// }; ////// data.Vehicle = vehicle; ////// } ////// else ////// { ////// var vehicle = new ApplicationExistingVehicleDetail() ////// { ////// IsStillToBeAcquired = false, ////// VehicleMakeDescription = (applicantVehicle != null && applicantVehicle.Element("vehiclemake") != null) ? (string)applicantVehicle.Element("vehiclemake") : null, ////// VehicleRegistrationNumber = (applicantVehicle != null && applicantVehicle.Element("registrationnumber") != null) ? (string)applicantVehicle.Element("registrationnumber") : null, ////// VIN = (applicantVehicle != null && applicantVehicle.Element("chassisnumber") != null) ? (string)applicantVehicle.Element("chassisnumber") : null, ////// EngineNumber = (applicantVehicle != null && applicantVehicle.Element("enginenumber") != null) ? (string)applicantVehicle.Element("enginenumber") : null, ////// SeatedCapacity = (applicantVehicle != null && applicantVehicle.Element("seatingcapacity") != null) ? applicantVehicle.Element("seatingcapacity").Value.ToInt16() : null, ////// GrossMass = (applicantVehicle != null && applicantVehicle.Element("grossmass") != null) ? applicantVehicle.Element("grossmass").Value.ToInt64() : null, ////// RoadworthyCertificateNumber = (applicantVehicle != null && applicantVehicle.Element("cofreferencenumber") != null) ? applicantVehicle.Element("cofreferencenumber").Value.ToString() : "", ////// RoadworthyExpiryDate = (applicantVehicle != null && applicantVehicle.Element("cofexpiry") != null) ? applicantVehicle.Element("cofexpiry").Value.ToDateTime() : null ////// }; ////// data.ExistingVehicle = vehicle; ////// } ////// #endregion ////// #region service types ////// foreach (var serviceType in applicantLicence.Descendants("servicetype")) ////// { ////// if (data.SourceApplicationID == (short)Common.SourceApplicationEnum.NTLIS) ////// { ////// var olasServiceTypeID = (serviceType.Element("licenceservicetypeid") != null) ? serviceType.Element("licenceservicetypeid").Value.ToInt32() : -1; ////// short serviceTypeID; ////// var serviceTypeDescription = ""; ////// #region Calculate LG service type id from OLAS servie type ////// switch (olasServiceTypeID) ////// { ////// case 4: /*Minibus taxi-type service*/ ////// serviceTypeID = 2; ////// serviceTypeDescription = "Unscheduled"; ////// break; ////// case 5: /*Charter service*/ ////// serviceTypeID = 3; ////// serviceTypeDescription = "Charter"; ////// break; ////// case 6: /*Metered taxi */ ////// serviceTypeID = 2; ////// serviceTypeDescription = "Unscheduled"; ////// break; ////// case 7: /*Staff service */ ////// serviceTypeID = 5; ////// serviceTypeDescription = "Staff"; ////// break; ////// case 8: /*Scheduled service */ ////// serviceTypeID = 1; ////// serviceTypeDescription = "Scheduled"; ////// break; ////// case 10: /*Unscheduled service */ ////// serviceTypeID = 2; ////// serviceTypeDescription = "Unscheduled"; ////// break; ////// case 13: /*Long distance service */ ////// serviceTypeID = 2; ////// serviceTypeDescription = "Unscheduled"; ////// break; ////// case 26: /*Tourist service*/ ////// serviceTypeID = 4; ////// serviceTypeDescription = "Tourist"; ////// break; ////// case 62: /*Educational Transport*/ ////// serviceTypeID = 6; ////// serviceTypeDescription = "Scholar"; ////// break; ////// case 63: /*Organised group*/ ////// serviceTypeID = 1; ////// serviceTypeDescription = "Scheduled"; ////// break; ////// default: ////// serviceTypeID = 8; //Unmapped type, so set to Other. ////// serviceTypeDescription = (string)serviceType.Element("servicetypedescription"); ////// break; ////// } ////// #endregion ////// #region ensure only 'other' service type is kept if mode is other ////// if (precheckDetail.ModeID == (short)Neo.LegitimateLicences.Common.ModeEnum.Other) ////// { ////// if (serviceTypeID == (short)Neo.LegitimateLicences.Common.ServiceTypeEnum.Other) ////// { ////// data.Services.Add(new ApplicationServiceDetail() ////// { ////// ServiceTypeID = serviceTypeID, ////// ServiceTypeDescription = serviceTypeDescription ////// }); ////// } ////// } ////// else ////// { ////// data.Services.Add(new ApplicationServiceDetail() ////// { ////// ServiceTypeID = serviceTypeID, ////// ServiceTypeDescription = serviceTypeDescription ////// }); ////// } ////// #endregion ////// //do not copy routes for special licence as a new route will be used for this type ////// if (data.LicenceIssueRequestTypeID != (short)Neo.LegitimateLicences.Common.LicenceIssueRequestTypeEnum.TemporarySpecialLicence) ////// { ////// #region Add routes from xml ////// foreach (var route in serviceType.Descendants("route")) ////// { ////// var routeName = ((string)route.Element("routename")).Replace("&", ""); ////// var routedescription = (route.Element("routedescription") != null) ? (string)route.Element("routedescription") : ""; ////// if (!String.IsNullOrWhiteSpace(routeName) ////// && !routedescription.ToLower().Replace(" ", "").StartsWith("conditions/restrictions") ////// && !routedescription.ToLower().StartsWith("conditions:")) ////// { ////// var olasID = route.Element("routeid").Value.ToInt32(); ////// var nationalRouteNumber = (string)route.Element("nationalroutenumber"); ////// var boardroutenumber = (string)route.Element("boardroutenumber"); ////// var routelengthkm = (route.Element("routelengthkm") != null) ? route.Element("routelengthkm").Value.ToInt32() : 0; ////// var origin = ""; ////// var destination = ""; ////// var verifiedRouteIDActive = Context.Pr_RouteSearch(-1, -1, nationalRouteNumber, boardroutenumber, -1, null, 1, null, -1, -1).ToList(); ////// if (verifiedRouteIDActive == null || verifiedRouteIDActive.Count() == 0) ////// { ////// var verifiedRouteID = Context.Pr_RouteUpsert(-1, 1, routeName, routedescription, null, null, nationalRouteNumber, boardroutenumber, routelengthkm, null, null, olasID, null, userID, "Create record based on imported data", false).FirstOrDefault().Value.ToInt32(); ////// var verifiedRoute = this.GetVerifiedRoute(verifiedRouteID.Value); ////// if (verifiedRoute.RouteStatusID != (short)RouteStatusEnum.Cancelled) ////// { ////// //create the required places ////// var sequence = 1; ////// foreach (var node in route.Descendants("routenode")) ////// { ////// var olasPlaceID = (node.Element("placeid") != null) ? node.Element("placeid").Value.ToInt32() : -1; ////// var placeDescription = (string)node.Element("placedescription"); ////// var placeTypeID = (node.Element("placetypeid") != null) ? node.Element("placetypeid").Value.ToInt16() : -1; //1 on 1 mapping between olas and legitimate ////// var waypointTypeID = (node.Element("waypointtypeid") != null) ? node.Element("waypointtypeid").Value.ToInt16() : -1; //1 on 1 mapping between olas and legitimate ////// var verifiedPlaceID = Context.Pr_PlaceUpsert(-1, placeDescription, placeTypeID, olasPlaceID, null, userID, "Create record based on imported data", false).FirstOrDefault().Value.ToInt32(); ////// var verifiedRouteNodeID = Context.Pr_RouteNodeAdd(verifiedRouteID, verifiedPlaceID, waypointTypeID, null, sequence, userID); ////// if (waypointTypeID == 1) ////// { ////// origin = placeDescription; ////// } ////// if (waypointTypeID == 4) ////// { ////// destination = placeDescription; ////// } ////// sequence++; ////// } ////// short appRouteStatusId = 2; //default to awaiting verification ////// if (verifiedRoute.RouteStatusID == 1) //active ////// { ////// appRouteStatusId = 3; //verfied ////// } ////// data.Routes.Add(new ApplicationRouteDetail() ////// { ////// ApplicationRouteDetailStatusID = appRouteStatusId, ////// BoardRouteNumber = boardroutenumber, ////// NationalRouteNumber = nationalRouteNumber, ////// RouteDescription = routedescription, ////// RouteDestination = destination, ////// RouteOrigin = origin, ////// RouteLength = routelengthkm, ////// VerifiedRouteID = verifiedRouteID, ////// RouteChangeTypeID = (short)RouteChangeTypeEnum.ExistingRouteOnLicence ////// }); ////// } ////// } ////// else ////// { ////// var verifiedRouteDetail = verifiedRouteIDActive.FirstOrDefault(); ////// data.Routes.Add(new ApplicationRouteDetail() ////// { ////// ApplicationRouteDetailStatusID = 3,//verified ////// BoardRouteNumber = verifiedRouteDetail.BoardRouteNumber, ////// NationalRouteNumber = verifiedRouteDetail.NationalRouteNumber, ////// RouteDescription = verifiedRouteDetail.RouteDescription, ////// RouteDestination = verifiedRouteDetail.RouteDestination, ////// RouteOrigin = verifiedRouteDetail.RouteOrigin, ////// RouteLength = verifiedRouteDetail.RouteLength, ////// VerifiedRouteID = verifiedRouteDetail.RouteID, ////// RouteChangeTypeID = (short)RouteChangeTypeEnum.ExistingRouteOnLicence ////// }); ////// } ////// } ////// } ////// #endregion ////// } ////// } ////// } ////// #endregion ////// #region add routes from association as we don't receive routes for ltps ////// if (data.IsLtpsConversion.Value == true && data.Routes.Count()==0) ////// { ////// if (precheckDetail.AssociationID.HasValue) ////// { ////// var associationRoutes = legitimateDb.GetVerifiedAssociationRoutes(precheckDetail.AssociationID.Value); ////// foreach (var route in associationRoutes) ////// { ////// var origin = (route.OriginPlaceID.HasValue) ? legitimateDb.GetVerifiedPlace(route.OriginPlaceID.Value).Description : ""; ////// var destination = (route.DestinationPlaceID.HasValue) ? legitimateDb.GetVerifiedPlace(route.DestinationPlaceID.Value).Description : ""; ////// var routeName = route.RouteName; ////// if (!String.IsNullOrWhiteSpace(routeName)) ////// { ////// short appRouteStatusId = 2; //default to awaiting verification ////// if (route.RouteStatusID == 1) //active ////// { ////// appRouteStatusId = 3; //verfied ////// } ////// data.Routes.Add(new ApplicationRouteDetail() ////// { ////// ApplicationRouteDetailStatusID = appRouteStatusId, ////// BoardRouteNumber = route.BoardRouteNumber, ////// NationalRouteNumber = route.NationalRouteNumber, ////// RouteDescription = route.Description, ////// RouteLength = route.RouteLength, ////// VerifiedRouteID = route.RouteID, ////// RouteDestination = destination, ////// RouteOrigin = origin, ////// RouteChangeTypeID = (short)RouteChangeTypeEnum.ExistingRouteOnLicence ////// }); ////// } ////// } ////// } ////// } ////// #endregion ////// #endregion ////// } ////// } ////// } ////// #endregion ////// #region default mode to precheck mode if not specified (for OLAS OLs and permits) ////// if (!data.Mode.ModeID.HasValue) ////// { ////// if (precheckDetail.ModeID.HasValue) ////// { ////// var mode = legitimateDb.GetMode(precheckDetail.ModeID.Value); ////// if (mode != null) ////// { ////// data.Mode.ModeID = mode.ModeID; ////// data.Mode.ModeDescription = mode.Description; ////// } ////// } ////// } ////// #endregion ////// return value; //////} #endregion ////#region LogPrintReceipt ////public bool LogPrintReceipt(long receiptDetailID, long userID, out string errorMessage) ////{ //// errorMessage = ""; //// try //// { //// Context.Pr_LogPrintReceipt(receiptDetailID, userID); //// } //// catch (Exception ex) //// { //// errorMessage = ex.Message; //// } //// return String.IsNullOrWhiteSpace(errorMessage); ////} ////#endregion ////#region SearchLicenceIssueRequestDetails ////public IEnumerable SearchLicenceIssueRequestDetails(long LicenceIssueRequestDetailID, short workflowInstanceStatusID, bool includeActiveTasksOnly, long userID, string workflowSteps) ////{ //// return Context.Pr_LicenceIssueRequestDetailsSearch(LicenceIssueRequestDetailID, workflowInstanceStatusID, workflowSteps, includeActiveTasksOnly, -1, false, userID).ToList(); ////} ////#endregion ////#region SearchNewRouteRequestDetails ////public IEnumerable SearchNewRouteRequestDetails(long newRouteRequestDetailID, short workflowInstanceStatusID, string description) ////{ //// return Context.Pr_NewRouteRequestDetailsSearch(newRouteRequestDetailID, workflowInstanceStatusID, description).ToList(); ////} ////#endregion //////#region GetPrecheckDetail //////public PrecheckDetail GetPrecheckDetail(long precheckDetialID) //////{ ////// return Context.PrecheckDetails.Where(a => a.PrecheckDetailID == precheckDetialID).FirstOrDefault(); //////} //////#endregion ////#region CheckSecurity ////public void CheckSecurity(long LicenceIssueRequestDetailID, string action, long userID) ////{ //// Context.Pr_ApplicationCheckSecurity(LicenceIssueRequestDetailID, action, userID); ////} ////#endregion ////#region GetSourceApplicationFromSourceSystem ////public Fn_GetSourceApplicationRecordsFromSourceSystem_Result GetSourceApplicationFromSourceSystem(string olPermitNumber, short sourceApplicationID, short modeID, bool includeActiveOnly, bool includeLastExpiredIfNoActiveFound) ////{ //// return Context.Fn_GetSourceApplicationRecordsFromSourceSystem(olPermitNumber, sourceApplicationID, modeID, includeActiveOnly, includeLastExpiredIfNoActiveFound).FirstOrDefault(); ////} ////#endregion ////#region PerformPrecheck ////public void PerformPrecheck(long precheckDetailID, short LicenceIssueRequestTypeID, short sourceApplicationID, string olPermitNumber, string iDNumber, long? associationID, string vehicleRegistrationNumber, bool checkData, long userID, short? modeID, bool calledFromSave) ////{ //// Context.Pr_PrecheckDetailsUpsert(precheckDetailID, LicenceIssueRequestTypeID, sourceApplicationID, null, olPermitNumber, iDNumber, null, vehicleRegistrationNumber, associationID, checkData, null, null, null, null, userID, modeID, calledFromSave); ////} ////#endregion } }