public void AddUsers(Users user)
        {
            try
            {
                if (string.IsNullOrEmpty(DBName))
                {
                    throw new Exception("Строка подключения к базе данных не должна быть пустой");
                }

                using (LiteDatabase db = new LiteDatabase(DBName))
                {
                    var users = db.GetCollection <Users>("Users");
                    users.Insert(user);
                }
                if (printMessage != null)
                {
                    printMessage.Invoke("Запись добавлена успешно");
                }

                if (sendNotification != null)
                {
                    sendNotification.Invoke(user);
                }
            }
            catch (Exception ex)
            {
                if (showError != null)
                {
                    showError.Invoke(ex);
                }
            }
        }
Exemple #2
0
 public void SendNotifications(object obj)
 {
     foreach (var plant in GetPlantsToWater())
     {
         SendNotification?.Invoke(this, new EventArgsSendNotifications(plant.UserId, plant.Name));
     }
 }
Exemple #3
0
        public void NotifyDriver(List <ActiveDrivers> availableDrivers, Rides rideInfo)
        {
            rides             = rideInfo;
            mAvailableDrivers = availableDrivers;
            if (mAvailableDrivers.Count >= 1 && mAvailableDrivers != null)
            {
                selectedDriver = mAvailableDrivers[0];


                //  notifyDriverRef = database.GetReference("driversAvailable/" + selectedDriver.ID + "/ride_id");
                // notifyDriverRef.SetValue(newTrip.RideID);

                string driverID    = selectedDriver.DriverId.ToString();
                string rideDetails = JsonConvert.SerializeObject(RideDetails());
                SendNotification.Invoke(this, new SendNotificationEventArgs {
                    driverID = driverID, rideDetails = rideDetails
                });
                //   hubConnection.InvokeAsync("NotifyDriver", driverID ,rideDetails );

                if (mAvailableDrivers.Count > 1)
                {
                    mAvailableDrivers.RemoveAt(0);
                }

                else if (mAvailableDrivers.Count == 1)
                {
                    //No more available drivers in our list
                    mAvailableDrivers = null;
                }

                RequestTimer.Enabled = true;
            }

            else
            {
                //No driver accepted
                RequestTimer.Enabled = false;
                NoDriverAcceptedRequest?.Invoke(this, new EventArgs());
            }
        }