using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using Neo.LegitimateLicences.Common; using Neo.Afx.ComponentModel; using Neo.Afx.Security; using Neo.LegitimateLicences.Common.Helpers; using System.Reflection; namespace Neo.LegitimateLicences.Data.Models { public partial class LegitimateDatabase { ////#region GetPrecheckDetail ////public PrecheckDetail GetPrecheckDetail(long precheckDetailID, long userID) ////{ //// var detail = (from q in Context.PrecheckDetails //// where q.PrecheckDetailID == precheckDetailID //// select q).FirstOrDefault(); //// return detail; ////} ////#endregion ////#region GetPrecheckDetailsIncomplete ////public IEnumerable GetPrecheckDetailsIncomplete() ////{ //// DateTime date = DateTime.Now; //// date = date.AddDays(-7); //// return Context.Vw_PrecheckDetailsIncomplete.Where(a => a.CreatedDate > date).ToList(); ////} ////#endregion ////#region GetPrecheckDetailIncompleteReasons ////public IEnumerable GetPrecheckDetailIncompleteReasons() ////{ //// return Context.PrecheckDetailIncompleteReasons.Where(a => !a.IsCancelled).ToList(); ////} ////#endregion ////#region SavePrecheckDetail ////public long? SavePrecheckDetail(long? precheckDetailID, short applicationRequestTypeID, short sourceApplicationID, string applicantName, string olPermitNumber, string idNumber, string chassisNumber, string vehicleRegistrationNumber, long? associationID, bool checkData, short? precheckDetailIncompleteReasonID, string contactEmail, string contactCell, UserProfile user, short? modeID, long? numberOfVehiclesRequired, out string notificationMessage, out string errorMessage) ////{ //// notificationMessage = ""; //// errorMessage = ""; //// try //// { //// if (modeID == (short)Neo.LegitimateLicences.Common.ModeEnum.Midibus || modeID == (short)Neo.LegitimateLicences.Common.ModeEnum.MinibusTaxi) //// { //// //todo re-enable region constraint when regions are ready //// var association = Context.Associations.Where(a => a.AssociationID == associationID).FirstOrDefault(); //// //var userRegion = user.Settings["RegionID"].ToInt64(); //// //var association = Context.Associations.Where(a => a.AssociationID == associationID && a.RegionID == userRegion.Value).FirstOrDefault(); //// if ((association != null && checkData) || !checkData) //// { //// precheckDetailID = Context.Pr_PrecheckDetailsUpsert(precheckDetailID, applicationRequestTypeID, sourceApplicationID, applicantName, olPermitNumber, idNumber, chassisNumber, vehicleRegistrationNumber, associationID, checkData, precheckDetailIncompleteReasonID, contactEmail, contactCell, numberOfVehiclesRequired, user.UserID, modeID, false).FirstOrDefault(); //// } //// else if (association == null && checkData) //// { //// precheckDetailID = -1L; //// association = Context.Associations.Include("Region").Where(a => a.AssociationID == associationID).FirstOrDefault(); //// errorMessage = "This application can not be created. You may not create applications cross region. The applicant will need to travel to the correct licencing office for his associations region (" + association.Region.Description + ")."; //// } //// } //// else //// { //// precheckDetailID = Context.Pr_PrecheckDetailsUpsert(precheckDetailID, applicationRequestTypeID, sourceApplicationID, applicantName, olPermitNumber, idNumber, chassisNumber, vehicleRegistrationNumber, null, checkData, precheckDetailIncompleteReasonID, contactEmail, contactCell, numberOfVehiclesRequired, user.UserID, modeID, false).FirstOrDefault(); //// } //// } //// catch (Exception ex) //// { //// errorMessage = GetInnermostMessage(ex); //// precheckDetailID = -1L; //// } //// #region Renewal notification message //// if (precheckDetailID.HasValue) //// { //// var precheck = Context.PrecheckDetails.Where(a => a.PrecheckDetailID == precheckDetailID).FirstOrDefault(); //// if (precheck != null) //// { //// if (precheck.IsRenewal && !ApplicationRequestHelper.IsRenewalType(precheck.ApplicationRequestTypeID)) //// { //// if (precheck.ApplicationRequestTypeID == 3 && precheck.IsLateRenewal) //// { //// errorMessage = "Please start a linked application of type Renewal and COV"; //// precheckDetailID = -1L; //// return -1L; //// } //// var additionalCost = Context.ApplicationRequestTypes.Where(a => a.ApplicationRequestTypeID == (short)Common.ApplicationRequestTypeEnum.Renewal).Select(a => a.Cost).FirstOrDefault(); //// if (precheck.IsLateRenewal) //// { //// notificationMessage = "Please note that your application has already expired and is within grace period for Renewal. If you wish to continue with your application you will be required to do a renewal at an additional cost of R" + additionalCost.ToString("F"); //// } //// else //// { //// notificationMessage = "Please note that your application is about to expire. If you wish to continue with your application you will be required to do a renewal at an additional cost of R" + additionalCost.ToString("F"); //// } //// } //// } //// } //// #endregion //// return precheckDetailID; ////} ////#endregion #region Get list of documents required for application type public List GetPrecheckDocumentList(long precheckDetailID) { return Context.Pr_PrecheckDocumentListGet(precheckDetailID).Where(a => a.IsMandatory.HasValue && a.IsMandatory.Value == true).OrderBy(a => a.DocumentTitle).ToList(); } #endregion } }