/// <summary>
        /// Update Caution List For Trucks
        /// </summary>
        /// <param name="truckDetails"></param>
        /// <returns></returns>
        public int UpdateCautionListForTrucks(TruckDetailsDTO truckDetails)
        {
            truckdetail truckdetailEntity = new truckdetail();
            AutoMapper.Mapper.Map(truckDetails, truckdetailEntity);

            ESalesUnityContainer.Container.Resolve<IGenericRepository<truckdetail>>().Update(truckdetailEntity);

            //return value
            return truckdetailEntity.Truck_Id;
        }
Пример #2
0
        /// <summary>
        /// Save And Update Truck Details For Customer
        /// </summary>
        /// <param name="truckDetails"></param>
        public int SaveAndUpdateTruckDetailsForCustomer(TruckDetailsDTO truckDetails)
        {
            truckdetail truckDetailsEntity = new truckdetail();
            AutoMapper.Mapper.Map(truckDetails, truckDetailsEntity);

            if (truckDetails.Truck_Id == 0)
            {
                ESalesUnityContainer.Container.Resolve<IGenericRepository<truckdetail>>().Save(truckDetailsEntity);
            }
            else
            {
                ESalesUnityContainer.Container.Resolve<IGenericRepository<truckdetail>>().Update(truckDetailsEntity);
            }

            //return the value
            return truckDetailsEntity.Truck_Id;
        }
Пример #3
0
     private void Fixuptruckdetail(truckdetail previousValue)
     {
         if (previousValue != null && previousValue.bookings.Contains(this))
         {
             previousValue.bookings.Remove(this);
         }
 
         if (truckdetail != null)
         {
             if (!truckdetail.bookings.Contains(this))
             {
                 truckdetail.bookings.Add(this);
             }
             if (Booking_Truck_Id != truckdetail.Truck_Id)
             {
                 Booking_Truck_Id = truckdetail.Truck_Id;
             }
         }
         else if (!_settingFK)
         {
             Booking_Truck_Id = null;
         }
     }
Пример #4
0
 /// <summary>
 /// Get inactive truck details by truck type and truck no and activate it
 /// </summary>
 /// <param></param>
 /// <returns></returns>
 public void ActivateInactiveTruck(int truckType, string truckNumber)
 {
     using (TransactionScope transaction = new TransactionScope())
     {
         if (truckType == 1)
         {
             TruckDetailsDTO _truckObj = new TruckDetailsDTO();
             truckdetail upTruckEntity = new truckdetail();
             AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<truckdetail>>()
                 .GetSingle(item => item.Truck_RegNo == truckNumber), _truckObj);
             _truckObj.Truck_IsDeleted = false;
             _truckObj.Truck_IsSuspended = false;
             AutoMapper.Mapper.Map(_truckObj, upTruckEntity);
             ESalesUnityContainer.Container.Resolve<IGenericRepository<truckdetail>>().Update(upTruckEntity);
         }
         else if (truckType == 2)
         {
             StandaloneTrucksDTO _standaloneTruckObj = new StandaloneTrucksDTO();
             standalonetruck upstandaloneTruckEntity = new standalonetruck();
             AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<standalonetruck>>()
                 .GetSingle(item => item.StandaloneTruck_RegNo == truckNumber), _standaloneTruckObj);
             _standaloneTruckObj.StandaloneTruck_IsDeleted = false;
             _standaloneTruckObj.StandaloneTruck_IsSuspended = false;
             AutoMapper.Mapper.Map(_standaloneTruckObj, upstandaloneTruckEntity);
             ESalesUnityContainer.Container.Resolve<IGenericRepository<standalonetruck>>().Update(upstandaloneTruckEntity);
         }
         transaction.Complete();
     }
 }
Пример #5
0
        /// <summary>
        /// Get all Inactive Truck Details
        /// </summary>
        /// <param></param>
        /// <returns></returns>
        public IList<TruckVerificationDTO> GetAllInactiveTruckDetails()
        {
            DateTime currDate = DateTime.Now.Date;
            int lastYear = (currDate.Year) - 1;
            DateTime lastDate = new DateTime(lastYear, currDate.Month, currDate.Day);

            // Settlements occured in last one year
            List<settlementofaccount> lstSettlementOfAcct = ESalesUnityContainer.Container.Resolve<IGenericRepository<settlementofaccount>>()
                .GetQuery().Where(item => item.Account_CreatedDate >= lastDate && item.Account_CreatedDate <= currDate)
                .OrderByDescending(F => F.Account_CreatedDate).ToList();
            
            List<SettlementOfAccountsDTO> lstAccount = new List<SettlementOfAccountsDTO>();
            if (lstSettlementOfAcct.Count > 0)
            {
                AutoMapper.Mapper.Map(lstSettlementOfAcct, lstAccount);
            }

            // List of trucks having settlement in last one year
            List<string> lstTrucks = lstAccount.Where(item => item.Account_Booking_Truck_RegNo != null).Select(item => item.Account_Booking_Truck_RegNo).ToList<string>();
            // List of all customer trucks
            List<TruckDetailsDTO> lstTruckDetails = new List<TruckDetailsDTO>();
            AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<truckdetail>>()
            .GetQuery().Where(item => item.Truck_IsBlacklisted == false && item.Truck_IsDeleted == false).ToList(), lstTruckDetails);

            // List of trucks that are not involved in settlement from last one year
            List<TruckDetailsDTO> listDistinctTrucks = lstTruckDetails.FindAll(T => !lstTrucks.Contains(T.Truck_RegNo));

            // Mark trucks as inactive
            foreach (TruckDetailsDTO item in listDistinctTrucks)
            {
                truckdetail upTruckEntity = new truckdetail();
                item.Truck_IsSuspended = true;
                item.Truck_IsDeleted = true;
                AutoMapper.Mapper.Map(item, upTruckEntity);
                ESalesUnityContainer.Container.Resolve<IGenericRepository<truckdetail>>().Update(upTruckEntity);
            }

            // List of standalone trucks having settlement in last one year
            List<string> lstStandaloneTrucks = lstAccount.Where(item => item.Account_Booking_StandaloneTruck_RegNo != null).Select(item => item.Account_Booking_StandaloneTruck_RegNo).ToList<string>();
            // List of all standalone trucks
            List<StandaloneTrucksDTO> lstStandaloneDetails = new List<StandaloneTrucksDTO>();
            AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<standalonetruck>>()
            .GetQuery().Where(item => item.StandaloneTruck_IsBlacklisted == false && item.StandaloneTruck_IsDeleted == false).ToList(), lstStandaloneDetails);

            // List of standalone trucks that are not involved in settlement from last one year
            List<StandaloneTrucksDTO> listDistinctStandaloneTrucks = lstStandaloneDetails.FindAll(T => !lstStandaloneTrucks.Contains(T.StandaloneTruck_RegNo));

            // Mark standalone trucks as inactive
            foreach (StandaloneTrucksDTO item in listDistinctStandaloneTrucks)
            {
                standalonetruck upStandaloneTruckEntity = new standalonetruck();
                item.StandaloneTruck_IsSuspended = true;
                item.StandaloneTruck_IsDeleted = true;
                AutoMapper.Mapper.Map(item, upStandaloneTruckEntity);
                ESalesUnityContainer.Container.Resolve<IGenericRepository<standalonetruck>>().Update(upStandaloneTruckEntity);
            }

            List<TruckVerificationDTO> trucks = new List<TruckVerificationDTO>();
            AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<truckverification>>()
            .GetQuery().Where(item => item.Truck_IsSuspended == 1 && item.Truck_IsDeleted == 1), trucks);
            return trucks;
        }
Пример #6
0
        /// <summary>
        /// Delete Truck
        /// </summary>
        /// <param name="truckDetails"></param>
        public void DeleteTruck(TruckDetailsDTO truckDetails)
        {
            using (TransactionScope transactionScope = new TransactionScope())
            {
                TruckDocService truckDocuments = new TruckDocService();
                IList<TruckDocDetailsDTO> lstTruckDocDetails = truckDocuments.GetTruckDocDetailsByTruckId(truckDetails.Truck_Id);

                (from truckDocDetail in lstTruckDocDetails select truckDocDetail).Update(
                    truckDocDetail => truckDocDetail.Truck_Doc_IsDeleted = true);

                foreach (var truckDocs in lstTruckDocDetails)
                {
                    DeleteTruckDocDetails(truckDocs);
                }

                truckdetail truckEntity = new truckdetail();
                AutoMapper.Mapper.Map(truckDetails, truckEntity);

                ESalesUnityContainer.Container.Resolve<IGenericRepository<truckdetail>>().Update(truckEntity);

                transactionScope.Complete();
            }
        }
Пример #7
0
     private void Fixuptruckdetail(truckdetail previousValue)
     {
         if (previousValue != null && previousValue.truckdocdetails.Contains(this))
         {
             previousValue.truckdocdetails.Remove(this);
         }
 
         if (truckdetail != null)
         {
             if (!truckdetail.truckdocdetails.Contains(this))
             {
                 truckdetail.truckdocdetails.Add(this);
             }
             if (Truck_Doc_TruckId != truckdetail.Truck_Id)
             {
                 Truck_Doc_TruckId = truckdetail.Truck_Id;
             }
         }
     }