コード例 #1
0
        public List <VehicleDetailViewModel> SearchVehicleDetail(int vehicleId)
        {
            List <VehicleDetail> result = _vehicleDetailRepository.GetMany(
                vd => vd.VehicleId == vehicleId).OrderByDescending(vd => vd.Id).ToList();
            List <VehicleDetailViewModel> mappedResult = new List <VehicleDetailViewModel>();

            return(Map(result, mappedResult));
        }
コード例 #2
0
        public List <InvoiceViewModel> SearchInvoice(DateTime?dateFrom, DateTime?dateTo,
                                                     DbConstant.InvoiceStatus invoiceStatus, int customerId,
                                                     int serviceCategoryId, int vehicleGroupId, string licenseNumber,
                                                     int paymentStatus)
        {
            List <Invoice> result = null;

            if (dateFrom.HasValue && dateTo.HasValue)
            {
                dateFrom = dateFrom.Value.Date;
                dateTo   = dateTo.Value.Date.AddDays(1).AddSeconds(-1);
                result   = _invoiceRepository.GetMany(c => c.CreateDate >= dateFrom && c.CreateDate <= dateTo).OrderBy(c => c.CreateDate).ToList();
            }
            else
            {
                result = _invoiceRepository.GetAll().OrderBy(c => c.CreateDate).ToList();
            }

            if ((int)invoiceStatus != 9)
            {
                result = result.Where(spk => spk.Status == (int)invoiceStatus).ToList();
            }

            if (customerId > 0)
            {
                result = result.Where(inv => inv.SPK.Vehicle.CustomerId == customerId).ToList();
            }

            if (vehicleGroupId > 0)
            {
                result = result.Where(inv => inv.SPK.Vehicle.VehicleGroupId == vehicleGroupId).ToList();
            }

            if (!string.IsNullOrEmpty(licenseNumber))
            {
                VehicleDetail vehicleDetail = _vehicleDetailRepository.GetMany(v => string.Compare(v.LicenseNumber, licenseNumber, true) == 1 &&
                                                                               v.Status == (int)DbConstant.DefaultDataStatus.Active).FirstOrDefault();
                if (vehicleDetail != null)
                {
                    result = result.Where(inv => inv.SPK.VehicleId == vehicleDetail.VehicleId).ToList();
                }
            }

            if (serviceCategoryId > 0)
            {
                result = result.Where(inv => inv.SPK.CategoryReferenceId == serviceCategoryId).ToList();
            }

            if (paymentStatus > -1)
            {
                result = result.Where(inv => inv.PaymentStatus == paymentStatus).ToList();
            }

            List <InvoiceViewModel> mappedResult = new List <InvoiceViewModel>();

            return(Map(result, mappedResult));
        }
コード例 #3
0
        public List <SPKViewModel> SearchSPK(string LicenseNumber, string code, int category, DateTime?dateFrom, DateTime?dateTo,
                                             int isContractWork, int customer)
        {
            List <SPK> result = _SPKRepository.GetMany(spk => spk.Status == (int)DbConstant.DefaultDataStatus.Active && spk.StatusCompletedId == (int)DbConstant.SPKCompletionStatus.Completed && spk.CategoryReference.Code != DbConstant.REF_SPK_CATEGORY_SALE).ToList();

            if (dateFrom.HasValue && dateTo.HasValue)
            {
                dateFrom = dateFrom.Value.Date;
                dateTo   = dateTo.Value.Date.AddDays(1).AddSeconds(-1);
                result   = result.Where(spk => spk.CreateDate >= dateFrom && spk.CreateDate <= dateTo).ToList();
            }

            if (!string.IsNullOrEmpty(LicenseNumber))
            {
                VehicleDetail vehicleDetail = _vehicleDetailRepository.GetMany(v => string.Compare(v.LicenseNumber, LicenseNumber, true) == 1 &&
                                                                               v.Status == (int)DbConstant.DefaultDataStatus.Active).FirstOrDefault();
                if (vehicleDetail != null)
                {
                    result = result.Where(spk => spk.VehicleId == vehicleDetail.VehicleId).ToList();
                }
            }

            if (customer > 0)
            {
                result = result.Where(spk => spk.Vehicle.CustomerId == customer).ToList();
            }

            if (!string.IsNullOrEmpty(code))
            {
                result = result.Where(spk => string.Compare(spk.Code, code, true) == 0).ToList();
            }

            if (category > 0)
            {
                result = result.Where(spk => spk.CategoryReferenceId == category).ToList();
            }

            if (isContractWork == 0)
            {
                result = result.Where(spk => spk.isContractWork == false).ToList();
            }

            if (isContractWork == 1)
            {
                result = result.Where(spk => spk.isContractWork == true).ToList();
            }

            List <SPKViewModel> mappedResult = new List <SPKViewModel>();

            return(Map(result, mappedResult));
        }
コード例 #4
0
        public void UpdateVehicleDetail(VehicleDetailViewModel vehicleDetail, VehicleViewModel vehicle, int userId)
        {
            DateTime serverTime = DateTime.Now;

            //set current active detail to expired if any
            VehicleDetail toBeExpired = _vehicleDetailRepository.GetMany(vd => vd.Status == (int)DbConstant.LicenseNumberStatus.Active).FirstOrDefault();

            if (toBeExpired != null)
            {
                toBeExpired.ModifyDate   = serverTime;
                toBeExpired.ModifyUserId = userId;
                toBeExpired.Status       = (int)DbConstant.LicenseNumberStatus.Expired;

                _vehicleDetailRepository.AttachNavigation <Vehicle>(toBeExpired.Vehicle);
                _vehicleDetailRepository.Update(toBeExpired);
                _unitOfWork.SaveChanges();
            }

            //insert new detail as active detail
            vehicleDetail.CreateDate   = serverTime;
            vehicleDetail.CreateUserId = userId;
            vehicleDetail.ModifyUserId = userId;
            vehicleDetail.VehicleId    = vehicle.Id;
            vehicleDetail.Status       = (int)DbConstant.LicenseNumberStatus.Active;
            VehicleDetail entityDetail = new VehicleDetail();

            Map(vehicleDetail, entityDetail);

            _vehicleDetailRepository.AttachNavigation <Vehicle>(entityDetail.Vehicle);
            _vehicleDetailRepository.Add(entityDetail);
            _unitOfWork.SaveChanges();

            //update active license number in vehicle
            if (vehicle != null)
            {
                vehicle.ModifyDate          = serverTime;
                vehicle.ModifyUserId        = userId;
                vehicle.ActiveLicenseNumber = vehicleDetail.LicenseNumber;
                Vehicle entity = _vehicleRepository.GetById(vehicle.Id);
                Map(vehicle, entity);

                _vehicleRepository.AttachNavigation <Customer>(entity.Customer);
                _vehicleRepository.Update(entity);
                _unitOfWork.SaveChanges();
            }

            _unitOfWork.SaveChanges();
        }
コード例 #5
0
        public List <SPKViewModel> SearchSPK(DateTime from, DateTime to, string LicenseNumber, string code, int category, DbConstant.ApprovalStatus approvalStatus,
                                             DbConstant.SPKPrintStatus printStatus, DbConstant.SPKCompletionStatus completedStatus, int isContractWork)
        {
            List <SPK> result = _SPKRepository.GetMany(spk =>
                                                       DbFunctions.TruncateTime(spk.CreateDate) >= DbFunctions.TruncateTime(from) &&
                                                       DbFunctions.TruncateTime(spk.CreateDate) <= DbFunctions.TruncateTime(to) &&
                                                       spk.Status == (int)DbConstant.DefaultDataStatus.Active).ToList();

            if ((int)completedStatus != 9)
            {
                result = result.Where(spk => spk.StatusCompletedId == (int)completedStatus).ToList();
            }

            if ((int)printStatus != 9)
            {
                result = result.Where(spk => spk.StatusPrintId == (int)printStatus).ToList();
            }

            if ((int)approvalStatus != 9)
            {
                result = result.Where(spk => spk.StatusApprovalId == (int)approvalStatus).ToList();
            }

            if (!string.IsNullOrEmpty(LicenseNumber))
            {
                IEnumerable <int> vehicleDetails = _vehicleDetailRepository.GetMany(v => v.LicenseNumber.Contains(LicenseNumber)).Select(v => v.Id).DefaultIfEmpty(0);
                if (vehicleDetails != null)
                {
                    result = result.Where(spk => vehicleDetails.Contains(spk.VehicleId)).ToList();
                }
            }

            if (!string.IsNullOrEmpty(code))
            {
                result = result.Where(spk => string.Compare(spk.Code, code, true) == 0).ToList();
            }

            if (category > 0)
            {
                result = result.Where(spk => spk.CategoryReferenceId == category).ToList();
            }

            if (isContractWork == 0)
            {
                result = result.Where(spk => spk.isContractWork == false).ToList();
            }

            if (isContractWork == 1)
            {
                result = result.Where(spk => spk.isContractWork == true).ToList();
            }

            List <SPKViewModel> mappedResult = new List <SPKViewModel>();

            if (result == null)
            {
                result = new List <SPK>();
            }

            return(Map(result, mappedResult));
        }
コード例 #6
0
 public DateTime GetLicenseNumberExpirationDate(string licenseNumber)
 {
     return(_vehicleDetailRepository.GetMany(vd => string.Compare(vd.LicenseNumber, licenseNumber, true) == 0).FirstOrDefault().ExpirationDate);
 }