Пример #1
0
 public static void ActiveUserAppointmentsListener()
 {
     FireBaseManager.GetFireBaseInstance().ActiveMyAppointmentsListener(currentUser.userID, currentUser.userType, delegate(List <AppointmentModel> appointments) {
         SetCurrentUserAppointments(appointments);
         DefineAppointmentsBadges();
     });
 }
Пример #2
0
 static void GetAllServicesProvidedFromCompanyAsUser()
 {
     Delegates.GetAllServicesProvidedFromCompany getAllServicesProvided = (services) => {
         (currentUser as CompanyModel).servicesProvided = services.ToDictionary(x => x.serviceID, x => (object)x);
     };
     FireBaseManager.GetFireBaseInstance().GetAllServicesProvidedFromCompany(currentUser.userID, getAllServicesProvided);
 }
Пример #3
0
 public static void RemoveMessage(MessageModel message, Delegates.GeneralListenerSuccess success)
 {
     FireBaseManager.GetFireBaseInstance().DeleteMessage(currentUser, message.id, delegate() {
         userMessages.Remove(message);
         success();
     });
 }
Пример #4
0
 public static void DeleteClient(UserModel client, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     FireBaseManager.GetFireBaseInstance().DeleteClientToCompany(currentUser.userID, client, delegate() {
         (currentUser as CompanyModel).clients.Remove(client.userID);
         success();
     }, fail);
 }
Пример #5
0
 public static void GetServicesFromAllResponsibles(Delegates.GetAllServicesProvided success)
 {
     success += (mresponsibles) => responsibles = mresponsibles;
     FireBaseManager.GetFireBaseInstance().UpdateServicesFromAllResponsibles(responsibles, success, delegate(string error) {
         Debug.LogError("Erro ao pegar os servicos: " + error);
     });
 }
    public void CreateNewUserWithEmailAndPassword(string name, string phone, string email, string password, Constants.UserType userType, Delegates.CreateNewUser success, Delegates.GeneralListenerFail fail)
    {
        auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
                fail("Criação cancelada");
                return;
            }
            if (task.IsFaulted)
            {
                fail(GetErrorMessage(task.Exception.InnerExceptions [0] as FirebaseException));
                Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + task.Exception);
                return;
            }

            // Firebase user has been created.
            user = task.Result;
            if (userType == Constants.UserType.User)
            {
                DataManager.currentUser = FireBaseManager.GetFireBaseInstance().CreateNewUser(auth.CurrentUser.UserId, name, phone);
            }

            var profile = new Firebase.Auth.UserProfile {
                DisplayName = name
            };
            UpdateUserProfile(profile);

            success(user.UserId);
            Debug.LogFormat("Firebase user created successfully: {0} ({1})",
                            user.DisplayName, user.UserId);
        });
    }
Пример #7
0
    public static void CreateNewMessageFromClientOrCompanyToResponsilbe(UserModel from, string toID, string message, string type, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
    {
        string companyID = "";
        var    mMessage  = new MessageModel(from.name, toID, message, DateTime.Now.ToString(Constants.dateformat), type);

        if (from.userType == Constants.UserType.Responsible.ToString())
        {
            companyID = (from as ResponsibleModel).companyID;
            FireBaseManager.GetFireBaseInstance().CreateNewMessage(mMessage, from.userID, toID, companyID, delegate() {
                success();
            }, delegate(string error) {
                fail(error);
            });
        }
        else if (from.userType == Constants.UserType.Client.ToString())
        {
            FireBaseManager.GetFireBaseInstance().CreateNewMessageScheduleByCompany(mMessage, toID, currentResponsible.companyID, delegate() {
                success();
            }, delegate(string error) {
                fail(error);
            });
        }
        else
        {
            fail("Usuário não é um profissional!");
        }
    }
Пример #8
0
 static void UpdateServiceResponsible(ServicesProvidedModel service, string responsibleID, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     FireBaseManager.GetFireBaseInstance().UpdateSeviceResponsible(responsibleID, service, delegate() {
         success();
     }, delegate(string error) {
         fail(error);
     });
 }
Пример #9
0
 public static void ActiveUserMessagesListener()
 {
     FireBaseManager.GetFireBaseInstance().ActiveUserMessagesListener(currentUser.userID, currentUser.userType, delegate(List <MessageModel> messages) {
         SetCurrentUserMessages(messages);
         userMessages = messages;
         DefineMessagesBadges();
     });
 }
Пример #10
0
    static void GetAllDaysWorkedFromCompanyAsUser()
    {
        Delegates.GetDaysWorked getDaysWorkedCallBack = delegate(List <bool> daysWorked) {
            (currentUser as CompanyModel).daysOfWork = daysWorked;
        };

        FireBaseManager.GetFireBaseInstance().GetAllDaysWorkedFromCompany(currentUser.userID, getDaysWorkedCallBack);
    }
Пример #11
0
    static void GetCompanyIDFromResponsibleAsUser()
    {
        Delegates.GetCompanyID getCompanyIDCallBack = delegate(string companyID) {
            (currentUser as ResponsibleModel).companyID = companyID;
        };

        FireBaseManager.GetFireBaseInstance().GetCompanyIDFromResponsible(currentUser.userID, getCompanyIDCallBack);
    }
Пример #12
0
    static void GetAllInitWorkFromCompanyAsUser()
    {
        Delegates.GetDaysTimeWorked getInitDaysWorkedCallBack = delegate(List <int> initTimeDays) {
            (currentUser as CompanyModel).timeToBeginWork = initTimeDays;
        };

        FireBaseManager.GetFireBaseInstance().GetAllInitDaysWorkedFromCompany(currentUser.userID, getInitDaysWorkedCallBack);
    }
Пример #13
0
    static void GetAllEndWorkFromCompanyAsUser()
    {
        Delegates.GetDaysTimeWorked getFinishDaysWorkedCallBack = delegate(List <int> finishTimeDays) {
            (currentUser as CompanyModel).timeToFinishWork = finishTimeDays;
        };

        FireBaseManager.GetFireBaseInstance().GetAllFinishDaysWorkedFromCompany(currentUser.userID, getFinishDaysWorkedCallBack);
    }
Пример #14
0
 static void GetAllClientsFromCompanyAsUser()
 {
     Delegates.GetAllClients getAllClients = (clients) => {
         (currentUser as CompanyModel).clients = clients.ToDictionary(x => x.userID, x => (object)x);
     };
     FireBaseManager.GetFireBaseInstance().GetAllClientsFromCompany(currentUser.userID, getAllClients, delegate(string error) {
     });
 }
Пример #15
0
 static void GetAllResponsablesFromCompanyAsUser()
 {
     Delegates.GetAllResponsibles getAllResponsiblesListener = (mresponsibles) => {
         responsibles = mresponsibles;
         (currentUser as CompanyModel).employees = mresponsibles.ToDictionary(x => x.userID, x => (object)x);
     };
     FireBaseManager.GetFireBaseInstance().GetAllResponsiblesFromCompany(currentUser.userID, getAllResponsiblesListener);
 }
Пример #16
0
 static void UpdateServiceCompany(ServicesProvidedModel service, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     FireBaseManager.GetFireBaseInstance().UpdateSeviceCompany(companyData.userID, service, delegate() {
         success();
     }, delegate(string error) {
         fail(error);
     });
 }
Пример #17
0
 public static void RemoveUser(UserModel user, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     FirebaseAPIHelper.GetFireBaseAPIHelperInstance().RemoveUser(user.userID, delegate() {
         FireBaseManager.GetFireBaseInstance().RemoveUser(user.userID, user.userType, delegate() {
             GetAllResponsablesFromCompanyAsUser();
             success();
         });
     }, fail);
 }
Пример #18
0
 public static void AddServiceToCompanyAsUser(ServicesProvidedModel service)
 {
     FireBaseManager.GetFireBaseInstance().AddServicesToCompany(currentUser.userID, new List <ServicesProvidedModel> ()
     {
         service
     }, delegate(List <ServicesProvidedModel> services) {
         services.ForEach(x => (currentUser as CompanyModel).servicesProvided.Add(x.serviceID, (object)x));
     });
 }
Пример #19
0
 public static void UpdateResponsibleServices(ResponsibleModel responsible, List <ServicesProvidedModel> services, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     FireBaseManager.GetFireBaseInstance().RemoveAllServcesFromResponsible(responsible.companyID, responsible, delegate() {
         FireBaseManager.GetFireBaseInstance().AddServicesToResponsible(responsible.companyID, responsible, services);
         success();
     }, delegate(string error) {
         fail(error);
     });
 }
Пример #20
0
 public static void GetResponsibleAppointments(Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     FireBaseManager.GetFireBaseInstance().GetResponsibleAppointments(currentResponsible.userID, delegate(List <AppointmentModel> appointments) {
         responsibleAppointmentList.Clear();
         appointments.ForEach(x => responsibleAppointmentList.Add(x));
         success();
     }, delegate(string error) {
         fail(error);
     });
 }
Пример #21
0
    public static void CreateNewResponsibleToCompanyAsUser(string reponsibleID, string name, List <ServicesProvidedModel> services, List <bool> daysWorked, List <int> initTime, List <int> finishTime, string phone = "")
    {
        var mPhone = phone;

        if (string.IsNullOrEmpty(phone))
        {
            mPhone = (currentUser as CompanyModel).phone;
        }
        responsibles.Add(FireBaseManager.GetFireBaseInstance().CreateNewResponsibleToCompany(reponsibleID, (currentUser as CompanyModel).userID, name, services, daysWorked, initTime, finishTime, mPhone));
    }
Пример #22
0
 public static void GetCurrentUserMessages(Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     FireBaseManager.GetFireBaseInstance().GetUserMessages(currentUser.userID, delegate(List <MessageModel> messages) {
         userMessages.Clear();
         userMessages = messages;
         success();
     }, delegate(string error) {
         fail(error);
     });
 }
Пример #23
0
 void CheckCompanies()
 {
     Loading = true;
     FireBaseManager.GetFireBaseInstance().GetAllCompanies(delegate(List <CompanyModel> companies) {
         DataManager.companiesList = companies;
         FillList();
     }, delegate(string error) {
         Loading = false;
         Error   = true;
     });
 }
Пример #24
0
    void Awake()
    {
        FirebaseApp.DefaultInstance.SetEditorDatabaseUrl(myProjectURL);
        reference = FirebaseDatabase.DefaultInstance.RootReference;
        reference.KeepSynced(true);

        if (_instance == null)
        {
            _instance = this;
        }
    }
Пример #25
0
 public static void SetMessagesToRead()
 {
     userMessages.ForEach(x => {
         if (x.isNew)
         {
             x.isNew = false;
             FireBaseManager.GetFireBaseInstance().UpdateMessage(currentUser, x);
         }
     });
     SetCurrentUserMessages(userMessages);
     DefineMessagesBadges();
 }
Пример #26
0
    public static void CreateNewClientToCompany(string name, string phone, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
    {
        var user = FireBaseManager.GetFireBaseInstance().CreateNewClient(name, phone);

        FireBaseManager.GetFireBaseInstance().AddClientToCompany(companyData.userID, user, delegate() {
            if (currentUser.userType == Constants.UserType.Company.ToString())
            {
                (currentUser as CompanyModel).clients.Add(user.userID, (object)user);
            }
            success();
        }, delegate(string error) {
            fail(error);
        });
    }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.HomePage);
            fireBaseManager = FireBaseManager.GetInstance();
            mTvWelcome      = FindViewById <TextView>(Resource.Id.txtWelcome);

            var user = fireBaseManager.mAuth?.CurrentUser;

            if (user != null)
            {
                mTvWelcome.Text = $"Welcome {user.DisplayName}";
                profile         = user.PhotoUrl;
            }

            mBtnSignOut        = FindViewById <Button>(Resource.Id.btnSignOut);
            mBtnSignOut.Click += MBtnSignOut_Click;

            mIvProfile = FindViewById <ImageView>(Resource.Id.ivProfile);


            //mIvProfile.SetImageURI(profile);
            if (profile != null)
            {
                var bit = GetImageBitmapFromUrl(profile?.ToString());
                mIvProfile.SetImageBitmap(bit);
            }
            // PushNotificatiob

            mPSMsg = FindViewById <TextView>(Resource.Id.playServiceMsg);

            if (Intent.Extras != null)
            {
                foreach (var key in Intent.Extras.KeySet())
                {
                    var value = Intent.Extras.GetString(key);
                    Log.Debug("Dev PushNot", "Key: {0} Value: {1}", key, value);
                }
            }
            IsPlayServicesAvailable();
            CreateNotificationChannel();
            var logTokenButton = FindViewById <Button>(Resource.Id.logTokenButton);

            logTokenButton.Click += delegate {
                //var instanceIdResult = await FirebaseInstanceId.Instance.GetInstanceId().AsAsync<IInstanceIdResult>();
                //var token = instanceIdResult.Token;
                Log.Debug("Dev PushNot", "InstanceID token: " + FirebaseInstanceId.Instance?.Token);
            };
        }
Пример #28
0
    public static void RemoveAppointmentFromUser(AppointmentModel appointment, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
    {
        FireBaseManager.GetFireBaseInstance().DeleteAppointment(appointment, delegate() {
            currentUser.appoitments.Remove(appointment.appointmentID);

            string minute = (appointment.minute.ToString() == "0" ? "00" : "0");
            var message   = string.Format("{0} desmarcou o agendamento de {1} marcado para dia {2} às {3}:{4}h", currentUser.name, appointment.description, appointment.data, appointment.hour, minute);
            CreateNewMessageFromUserToResponsilbe(currentUser, currentResponsible, message, Constants.MessageType.RemoveAppointment.ToString(), delegate() {
            }, delegate(string error) {
            });
            success();
        }, delegate(string error) {
            fail(error);
        });
    }
Пример #29
0
    public static void CreateCompanyDataWithMockData(string companyID)
    {
        companyData = FireBaseManager.GetFireBaseInstance().CreateNewCompany(companyID, "Minha Empresa", "32456789", "Campinas", "Rua Joãozinho", "13082660");

//		var servicesList = new List<ServicesProvidedModel> ();
//		servicesList.Add (new ServicesProvidedModel ("Cabeleireiro", 1));
//		servicesList.Add (new ServicesProvidedModel ("Manicure", 0.5f));
//		servicesList.Add (new ServicesProvidedModel ("Pedicure", 1.5f));

//		responsibles.Add (FireBaseManager.GetFireBaseInstance ().CreateNewResponsibleToCompany (companyData.userID, "Funcionario 1", new List<ServicesProvidedModel> { servicesList [0] }));
//		responsibles.Add (FireBaseManager.GetFireBaseInstance ().CreateNewResponsibleToCompany (companyData.userID, "Funcionario 2", new List<ServicesProvidedModel> { servicesList [1] }));
//		responsibles.Add (FireBaseManager.GetFireBaseInstance ().CreateNewResponsibleToCompany (companyData.userID, "Funcionario 3", new List<ServicesProvidedModel> { servicesList [2] }));
//		responsibles.Add (FireBaseManager.GetFireBaseInstance ().CreateNewResponsibleToCompany (companyData.userID, "Funcionario 4", servicesList));

        companyData.employees = responsibles.ToDictionary(x => x.userID, x => (object)x);
    }
Пример #30
0
 public static void SetMyAppointmentsAsRead()
 {
     if (currentUser.appoitments != null)
     {
         foreach (var appointmentKey in currentUser.appoitments.Keys)
         {
             AppointmentModel appointment;
             appointment = (AppointmentModel)currentUser.appoitments [appointmentKey];
             if (appointment.isNew)
             {
                 appointment.isNew = false;
                 FireBaseManager.GetFireBaseInstance().UpdateMyAppointment(currentUser, appointmentKey);
             }
         }
     }
     DefineAppointmentsBadges();
 }