public IEnumerable <DriverLicenseViewModel> GetByDriverC(string driverC)
        {
            var source = _driverLicenseRepository.Query(x => x.DriverC == driverC);

            return(from a in _driverLicenseRepository.GetAllQueryable()
                   join b in _licenseRepository.GetAllQueryable() on a.LicenseC equals b.LicenseC
                   where a.DriverC == driverC
                   select new DriverLicenseViewModel()
            {
                DriverC = a.DriverC,
                LicenseC = a.LicenseC,
                LicenseN = b.LicenseN,
                DriverLicenseD = a.DriverLicenseD,
                DriverLicenseNo = a.DriverLicenseNo,
                ExpiryD = a.ExpiryD
            });
        }
Example #2
0
        public void DeleteDriver(string id)
        {
            var driverToRemove = _driverRepository.Get(c => c.DriverC == id);

            if (driverToRemove != null)
            {
                _driverRepository.Delete(driverToRemove);

                var deleteItem = _driverLicenseRepository.Query(x => x.DriverC == id);
                if (deleteItem.Any())
                {
                    foreach (DriverLicense_M item in deleteItem)
                    {
                        _driverLicenseRepository.Delete(item);
                    }
                }

                SaveDriver();
            }
        }