Ejemplo n.º 1
0
        public static Driver CreateFromYandexDriver(YandexDriverModel m)
        {
            Driver driver = new Driver
            {
                Status               = m.Status,
                YandexId             = m.YandexId,
                Balance              = m.Balance,
                CarId                = m.CarId,
                DateCreate           = m.Driver.DateCreate,
                DateStart            = m.Driver.DateStart,
                FirstName            = m.Driver.FirstName,
                Id                   = m.Driver.InternalId,
                LastName             = m.Driver.LastName,
                LicenseDateEnd       = m.Driver.LicenseDateEnd,
                LicenseDateOf        = m.Driver.LicenseDateOf,
                LicenseNumber        = m.Driver.LicenseNumber,
                LicenseSeries        = m.Driver.LicenseSeries,
                PersonalPostTerminal = m.Driver.PersonalPostTerminal,
                Phones               = m.Driver.Phones,
                RuleId               = m.Driver.RuleId,
                Surname              = m.Driver.Surname,
                WorkStatusType       = m.Driver.WorkStatusType
            };

            return(driver);
        }
Ejemplo n.º 2
0
 public void UpdateFromYandexDriver(YandexDriverModel ydm)
 {
     Status               = ydm.Status;
     YandexId             = ydm.YandexId;
     Balance              = ydm.Balance;
     CarId                = ydm.CarId;
     DateCreate           = ydm.Driver.DateCreate;
     DateStart            = ydm.Driver.DateStart;
     FirstName            = ydm.Driver.FirstName;
     LastName             = ydm.Driver.LastName;
     LicenseDateEnd       = ydm.Driver.LicenseDateEnd;
     LicenseDateOf        = ydm.Driver.LicenseDateOf;
     LicenseNumber        = ydm.Driver.LicenseNumber;
     LicenseSeries        = ydm.Driver.LicenseSeries;
     PersonalPostTerminal = ydm.Driver.PersonalPostTerminal;
     Phones               = ydm.Driver.Phones;
     RuleId               = ydm.Driver.RuleId;
     Surname              = ydm.Driver.Surname;
     WorkStatusType       = ydm.Driver.WorkStatusType;
 }
Ejemplo n.º 3
0
 public bool HasChanges(YandexDriverModel ymd)
 {
     return
         (YandexId != ymd.YandexId ||
          Status != ymd.Status ||
          Math.Abs(Balance - ymd.Balance) > 0.1 ||
          CarId != ymd.CarId ||
          DateCreate != ymd.Driver.DateCreate ||
          DateStart != ymd.Driver.DateStart ||
          FirstName != ymd.Driver.FirstName ||
          Id != ymd.Driver.InternalId ||
          LastName != ymd.Driver.LastName ||
          LicenseDateEnd != ymd.Driver.LicenseDateEnd ||
          LicenseDateOf != ymd.Driver.LicenseDateOf ||
          LicenseNumber != ymd.Driver.LicenseNumber ||
          LicenseSeries != ymd.Driver.LicenseSeries ||
          PersonalPostTerminal != ymd.Driver.PersonalPostTerminal ||
          Phones != ymd.Driver.Phones ||
          RuleId != ymd.Driver.RuleId ||
          Surname != ymd.Driver.Surname ||
          WorkStatusType != ymd.Driver.WorkStatusType);
 }
Ejemplo n.º 4
0
 public bool CreateOrUpdateDriver(YandexDriverModel driver)
 {
     try
     {
         var res = Drivers.Find(driver.Driver.InternalId);
         if (res == null)
         {
             _logger.Info($"New driver {driver}");
             Drivers.Add(Driver.CreateFromYandexDriver(driver));
         }
         else
         {
             if (!res.HasChanges(driver))
             {
                 return(true);
             }
             _logger.Debug($"Update driver data: {driver}");
             res.UpdateFromYandexDriver(driver);
         }
         SaveChanges();
         if (res == null)
         {
             Notifications.Add(new Notification
             {
                 InternalId  = driver.Driver.InternalId,
                 Message     = $"Найден новый водитель [{driver}]!",
                 Type        = "NewDriver",
                 DateCreated = DateTime.Now
             });
             SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }