Пример #1
0
        protected override void Add()
        {
            if (Document.Created == default(DateTime))
            {
                Document.Created = DateTime.Now;
            }

            if (Document.CalibrationTime == null)
            {
                Document.CalibrationTime = DateTime.Now;
            }

            if (SelectedCustomerContact == null)
            {
                CustomerContactRepository.Add(new CustomerContact
                {
                    Name = Document.CustomerContact
                });
            }

            AddInspectionInfoCommand.Execute(null);

            TachographDocumentRepository.AddOrUpdate(Document);
            ConnectHelper.Upload(Document);
        }
Пример #2
0
        protected override void RegistrationChanged(string registrationNumber)
        {
            if (string.IsNullOrEmpty(registrationNumber) || !Document.IsDigital)
            {
                return;
            }

            //Remove all spaces from registration number
            Document.RegistrationNumber = registrationNumber.Replace(" ", string.Empty).ToUpper();

            if (!TachographDocumentRepository.Any())
            {
                return;
            }

            TachographDocument match = TachographDocumentRepository.Where(doc => string.Equals(doc.RegistrationNumber, Document.RegistrationNumber, StringComparison.CurrentCultureIgnoreCase))
                                       .OrderByDescending(doc => doc.Created)
                                       .FirstOrDefault();

            if (match == null && registrationNumber.Length > 8)
            {
                match = TachographDocumentRepository.Where(doc => string.Equals(doc.VIN, registrationNumber, StringComparison.CurrentCultureIgnoreCase))
                        .OrderByDescending(doc => doc.Created)
                        .FirstOrDefault();
            }

            if (match == null)
            {
                return;
            }

            Document.CalibrationTime  = DateTime.Now;
            Document.CardSerialNumber = match.CardSerialNumber;

            if (Document.Created == default(DateTime))
            {
                Document.Created = DateTime.Now;
            }
            Document.CustomerContact               = match.CustomerContact;
            Document.InspectionDate                = DateTime.Now;
            Document.InspectionInfo                = match.InspectionInfo;
            Document.IsDigital                     = match.IsDigital;
            Document.MinorWorkDetails              = match.MinorWorkDetails;
            Document.Office                        = match.Office;
            Document.RegistrationNumber            = match.RegistrationNumber;
            Document.SerialNumber                  = match.SerialNumber;
            Document.TachographAdapterLocation     = match.TachographAdapterLocation;
            Document.TachographAdapterSerialNumber = match.TachographAdapterSerialNumber;
            Document.TachographCableColor          = match.TachographCableColor;
            Document.TachographHasAdapter          = match.TachographHasAdapter;
            Document.TachographMake                = match.TachographMake;
            Document.TachographModel               = match.TachographModel;
            Document.TachographType                = match.TachographType;
            Document.Tampered                      = match.Tampered;
            Document.TyreSize                      = match.TyreSize;
            Document.VehicleMake                   = match.VehicleMake;
            Document.VehicleModel                  = match.VehicleModel;
            Document.VehicleType                   = match.VehicleType;
            Document.VIN = match.VIN;

            SelectedCustomerContact = CustomerContacts.FirstOrDefault(c => string.Equals(c.Name, match.CustomerContact, StringComparison.CurrentCultureIgnoreCase));
        }
Пример #3
0
 protected override void Update()
 {
     TachographDocumentRepository.AddOrUpdate(Document);
     ConnectHelper.Upload(Document, true);
 }