Пример #1
0
        private bool ValidPayments(string plateNumber, int customerId)
        {
            bool hasValidPayments;

            using (PemsUsProEntities context = new PemsUsProEntities())
            {
                hasValidPayments = context.EnfVendorTransactions.Any(x => x.PlateNumber.Equals(plateNumber, StringComparison.OrdinalIgnoreCase) &&
                                                                     x.EnfCustomerId.HasValue && x.EnfCustomerId.Value.Equals(customerId));
                if (hasValidPayments)
                {
                    return(true);
                }
                var currentDateTime = UtcToZoneDateTime(DateTime.Now, customerId);
                var dayBefore       = DateTime.Now.AddDays(-1);
                hasValidPayments = (from pcp in context.PayByCellPlateTxns
                                    join pv in context.ParkVehicles on pcp.VehicleId equals pv.VehicleID
                                    //join vt in context.EnfVendorTransactions on pv.LPNumber equals vt.PlateNumber
                                    where
                                    pv.LPNumber == plateNumber && pcp.CustomerId == customerId &&
                                    (pcp.TransDateTime > dayBefore && pcp.TransDateTime < currentDateTime) &&
                                    pcp.ExpiryDateTime > currentDateTime
                                    select pv).Any();
            }
            return(hasValidPayments);
        }
Пример #2
0
        public static DateTime UtcToZoneDateTime(DateTime dateTime, int customerId)
        {
            string clientZone;
            var    customerZoneId = 0;

            using (PEMSRBAC_US_PROEntities context = new PEMSRBAC_US_PROEntities())
            {
                customerZoneId = context.CustomerProfiles.FirstOrDefault(x => x.CustomerId == customerId)?.TimeZoneID ??
                                 0;
            }
            if (customerZoneId < 1)
            {
                return(DateTime.UtcNow);
            }
            using (PemsUsProEntities context = new PemsUsProEntities())
            {
                clientZone = context.TimeZones.FirstOrDefault(x => x.TimeZoneID == customerZoneId)?.TimeZoneName;
            }
            if (string.IsNullOrWhiteSpace(clientZone))
            {
                return(DateTime.UtcNow);
            }
            try
            {
                TimeZoneInfo clientTimeZone   = TimeZoneInfo.FindSystemTimeZoneById(clientZone);
                DateTime     converteDateTime = TimeZoneInfo.ConvertTimeFromUtc(dateTime, clientTimeZone);
                return(converteDateTime);
            }
            catch (Exception e)
            {
                return(DateTime.UtcNow);
            }
        }
Пример #3
0
        private bool NoMatches(string plateNumber, int customerId)
        {
            bool noMatch;

            using (PemsUsProEntities context = new PemsUsProEntities())
            {
                noMatch = !context.EnfVendorTransactions.Any(
                    x => x.PlateNumber.Equals(plateNumber, StringComparison.OrdinalIgnoreCase) &&
                    x.EnfCustomerId == customerId);
                if (noMatch)
                {
                    noMatch =
                        !context.ENF_Permits.Any(
                            x => x.ENFPlateNo.Equals(plateNumber, StringComparison.OrdinalIgnoreCase) &&
                            x.ENFCustomerId.Equals(customerId));
                }
                if (noMatch)
                {
                    noMatch = !(from pcp in context.PayByCellPlateTxns
                                join pv in context.ParkVehicles on pcp.VehicleId equals pv.VehicleID
                                where pv.LPNumber == plateNumber
                                select pv).Any();
                }
            }
            return(noMatch);
        }
Пример #4
0
 private string Violation(string plateNumber, int customerId)
 {
     using (PemsUsProEntities context = new PemsUsProEntities())
     {
         return(context.ENF_Permits.FirstOrDefault(x =>
                                                   x.ENFPlateNo.Equals(plateNumber, StringComparison.OrdinalIgnoreCase) &&
                                                   x.ENFCustomerId.Equals(customerId))?.ENFType);
     }
 }
Пример #5
0
 private string GetRateName(int customerId, string plateNumber)
 {
     if (customerId == 7012)
     {
         using (PemsUsProEntities context = new PemsUsProEntities())
         {
             return((from txn in context.PayByCellPlateTxns
                     join pv in context.ParkVehicles on txn.VehicleId equals pv.VehicleID
                     where txn.CustomerId == customerId && pv.LPNumber == plateNumber
                     select txn.TxnSeqNum).FirstOrDefault());
         }
     }
     return(string.Empty);
 }
Пример #6
0
        private bool Expired(string plateNumber, int customerId)
        {
            bool isExpired;

            using (PemsUsProEntities context = new PemsUsProEntities())
            {
                var currentDateTime = UtcToZoneDateTime(DateTime.Now, customerId);
                isExpired = !context.EnfVendorTransactions.Any(x =>
                                                               x.PlateNumber.Equals(plateNumber, StringComparison.OrdinalIgnoreCase) &&
                                                               x.EnfCustomerId.HasValue && x.EnfCustomerId.Value.Equals(customerId) &&
                                                               x.ExpiryDate < currentDateTime);
                if (isExpired)
                {
                    isExpired =
                        (from pv in context.ParkVehicles
                         join pcp in context.PayByCellPlateTxns on pv.VehicleID equals pcp.VehicleId
                         where pv.LPNumber == plateNumber && pcp.CustomerId == customerId && pcp.ExpiryDateTime < currentDateTime
                         select pv).Any();
                }
            }

            return(isExpired);
        }