예제 #1
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);
 }
예제 #2
0
 public void DeleteAppointment(AppointmentModel appointment, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     FirebaseDatabase.DefaultInstance.GetReference(DBTable.Appointments.ToString()).Child(appointment.appointmentID).RemoveValueAsync().ContinueWith(task => {
         if (task.IsFaulted)
         {
             fail(task.Exception.ToString());
         }
         else
         {
             FirebaseDatabase.DefaultInstance.GetReference(DBTable.User.ToString()).Child(appointment.userID).Child(Parameters.appointments.ToString()).Child(appointment.appointmentID).RemoveValueAsync().ContinueWith(task2 => {
                 if (task2.IsFaulted)
                 {
                     fail(task2.Exception.ToString());
                 }
                 else
                 {
                     FirebaseDatabase.DefaultInstance.GetReference(DBTable.Responsible.ToString()).Child(appointment.responsableID).Child(Parameters.appointments.ToString()).Child(appointment.appointmentID).RemoveValueAsync().ContinueWith(task3 => {
                         if (task3.IsFaulted)
                         {
                             fail(task3.Exception.ToString());
                         }
                         else
                         {
                             success();
                         }
                     });
                 }
             });
         }
     });
 }
예제 #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 UpdateService(ServicesProvidedModel service, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
    {
        bool mError = false;

        UpdateServiceCompany(service, delegate() {
            GetAllResponsablesFromCompany(companyData.userID, delegate(List <ResponsibleModel> responsables) {
                responsables.ForEach(x => {
                    UpdateServiceResponsible(service, x.userID, delegate() {
                    }, delegate(string error) {
                        mError = true;
                    });
                });
                if (mError)
                {
                    fail("");
                }
                else
                {
                    success();
                }
            });
        }, delegate(string error) {
            fail(error);
        });
    }
예제 #5
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);
     });
 }
예제 #6
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);
 }
예제 #7
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);
     });
 }
예제 #8
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);
     });
 }
예제 #9
0
 public void DeleteClientToCompany(string companyID, UserModel userModel, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     reference.Child(DBTable.Company.ToString()).Child(companyID).Child(Parameters.clients.ToString()).Child(userModel.userID).RemoveValueAsync().ContinueWith(task => {
         if (task.IsFaulted)
         {
             fail(task.Exception.ToString());
         }
         else if (task.IsCompleted)
         {
             success();
         }
     });
 }
예제 #10
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);
        });
    }
예제 #11
0
    public void AddClientToCompany(string companyID, UserModel userModel, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
    {
        string json = JsonUtility.ToJson(userModel);

        reference.Child(DBTable.Company.ToString()).Child(companyID).Child(Parameters.clients.ToString()).Child(userModel.userID).SetRawJsonValueAsync(json).ContinueWith(task => {
            if (task.IsFaulted)
            {
                fail(task.Exception.ToString());
            }
            else if (task.IsCompleted)
            {
                success();
            }
        });
    }
예제 #12
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);
        });
    }
예제 #13
0
    public void UpdateSeviceCompany(string companyID, ServicesProvidedModel service, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
    {
        string json = JsonUtility.ToJson(service);

        reference.Child(DBTable.Company.ToString()).Child(companyID).Child(Parameters.servicesProvided.ToString()).Child(service.serviceID).SetRawJsonValueAsync(json).ContinueWith(task => {
            if (task.IsFaulted)
            {
                fail(task.Exception.ToString());
            }
            else if (task.IsCompleted)
            {
                success();
            }
        });
    }
예제 #14
0
    public void RemoveUser(string userID, string userType, Delegates.GeneralListenerSuccess success)
    {
        if (userType == Constants.UserType.Responsible.ToString())
        {
            FirebaseDatabase.DefaultInstance.GetReference(DBTable.Responsible.ToString()).Child(userID).RemoveValueAsync();
        }

        FirebaseDatabase.DefaultInstance.GetReference(DBTable.User.ToString()).Child(userID).RemoveValueAsync()
        .ContinueWith(task => {
            if (task.IsFaulted)
            {
            }
            else
            {
                success();
            }
        });
    }
예제 #15
0
 public void DeleteMessage(UserModel user, string messageID, Delegates.GeneralListenerSuccess success)
 {
     if (user is ResponsibleModel)
     {
         FirebaseDatabase.DefaultInstance.GetReference(DBTable.Responsible.ToString()).Child(user.userID).Child(Parameters.messages.ToString()).Child(messageID).RemoveValueAsync()
         .ContinueWith(task => {
             if (task.IsFaulted)
             {
             }
             else
             {
                 success();
             }
         });
     }
     else if (user is CompanyModel)
     {
         FirebaseDatabase.DefaultInstance.GetReference(DBTable.Company.ToString()).Child(user.userID).Child(Parameters.messages.ToString()).Child(messageID).RemoveValueAsync()
         .ContinueWith(task => {
             if (task.IsFaulted)
             {
             }
             else
             {
                 success();
             }
         });
     }
     else
     {
         FirebaseDatabase.DefaultInstance.GetReference(DBTable.User.ToString()).Child(user.userID).Child(Parameters.messages.ToString()).Child(messageID).RemoveValueAsync()
         .ContinueWith(task => {
             if (task.IsFaulted)
             {
             }
             else
             {
                 success();
             }
         });
     }
 }
예제 #16
0
    IEnumerator RemoveUserAux(string userID, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
    {
        WWWForm form = new WWWForm();

        form.AddField("uid", userID);

        using (UnityWebRequest w = UnityWebRequest.Post(removeUserURL, form)) {
            yield return(w.Send());

            if (w.isNetworkError || w.isHttpError)
            {
                Debug.Log(w.error);
                fail(w.error.ToString());
            }
            else
            {
                Debug.Log("User created!");
                success();
            }
        }
    }
예제 #17
0
    public static void CreateNewAppointment(UserModel user, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
    {
        var appointment = new AppointmentModel(dateNewAppointment, user.userID, user.name, currentResponsible.userID, currentResponsible.name, currentservice.name, Mathf.RoundToInt((currentservice.duration) * 60));

        FireBaseManager.GetFireBaseInstance().CreateNewAppoitment(user, currentResponsible, appointment, delegate(AppointmentModel mappointment) {
            success();
            string minute = (dateNewAppointment.Minute == 0 ? "00" : "0");
            var message   = string.Format("{0} realizou novo agendamento de {1} para dia {2}/{3} às {4}:{5}h", user.name, currentservice.name, dateNewAppointment.Day, dateNewAppointment.Month, dateNewAppointment.Hour, minute);
            if (user.userType == Constants.UserType.User.ToString())
            {
                CreateNewMessageFromUserToResponsilbe(user, currentResponsible, message, Constants.MessageType.ScheduleAppointment.ToString(), delegate() {
                }, delegate(string error) {
                });
            }
            else
            {
                CreateNewMessageFromClientOrCompanyToResponsilbe(user, currentResponsible.userID, message, Constants.MessageType.ScheduleAppointment.ToString(), delegate() {
                }, delegate(string error) {
                });
            }
        }, fail);
    }
    public void ForgotPassword(string email, Delegates.GeneralListenerSuccess successListener, Delegates.GeneralListenerFail failListener)
    {
        if (user != null)
        {
            auth.SendPasswordResetEmailAsync(email).ContinueWith(task => {
                if (task.IsCanceled)
                {
                    Debug.LogError("SendPasswordResetEmailAsync was canceled.");
                    failListener("SendPasswordResetEmailAsync was canceled.");
                    return;
                }
                if (task.IsFaulted)
                {
                    Debug.LogError("SendPasswordResetEmailAsync encountered an error: " + task.Exception);
                    failListener(GetErrorMessage(task.Exception.InnerExceptions [0] as FirebaseException));
                    return;
                }

                Debug.Log("Password reset email sent successfully.");
                successListener();
            });
        }
    }
예제 #19
0
    public static void LoadUserInfoAux(string ID, Delegates.GeneralListenerSuccess success)
    {
//		Empresa:
//		string ID = "z0iJvJUBK2aK2BP2OAuACDrNMSn1";
//		Gustavo:
//		string ID = "4VpwAC7NBjVSW3ab86sgAnG1mC83";
        FireBaseManager.GetFireBaseInstance().GetUserByID(ID, delegate(UserModel user) {
            if (user.userType == Constants.UserType.Company.ToString())
            {
                currentUser = new CompanyModel(user);
                GetAllResponsablesFromCompanyAsUser();
                GetAllClientsFromCompanyAsUser();
                GetAllServicesProvidedFromCompanyAsUser();
                GetAllDaysWorkedFromCompanyAsUser();
                GetAllInitWorkFromCompanyAsUser();
                GetAllEndWorkFromCompanyAsUser();
                companyData = new CompanyModel(user);
            }
            else if (user.userType == Constants.UserType.Responsible.ToString())
            {
                currentUser = new ResponsibleModel(user);
                GetCompanyIDFromResponsibleAsUser();
                FireBaseManager.GetFireBaseInstance().GetUserByID(ID, delegate(UserModel muser) {
                    companyData = new CompanyModel(muser);
                });
            }
            else
            {
                currentUser = user;
            }
            FirebaseMessaging.SubscribeToTopic();
            MainPageController.GetMainPageInstance().UpdateText();
            success();
            ActiveListeners();
        });
    }
예제 #20
0
 public void RemoveUser(string userID, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     StartCoroutine(RemoveUserAux(userID, success, fail));
 }
예제 #21
0
    public void CreateNewMessageScheduleByCompany(MessageModel message, string responsibleID, string userID, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
    {
        string messageID = reference.Child(DBTable.User.ToString()).Push().Key;

        message.id = messageID;

        string json = JsonUtility.ToJson(message);

        reference.Child(DBTable.Company.ToString()).Child(userID).Child(Parameters.messages + "/" + messageID).SetRawJsonValueAsync(json).ContinueWith(task => {
            if (task.IsFaulted)
            {
                fail(task.Exception.ToString());
            }
            else if (task.IsCompleted)
            {
                reference.Child(DBTable.Responsible.ToString()).Child(responsibleID).Child(Parameters.messages + "/" + messageID).SetRawJsonValueAsync(json).ContinueWith(task2 => {
                    if (task2.IsFaulted)
                    {
                        fail(task2.Exception.ToString());
                    }
                    else if (task2.IsCompleted)
                    {
                        success();
                    }
                });
            }
        });
    }
예제 #22
0
 public void RemoveAllServcesFromResponsible(string companyID, ResponsibleModel responsible, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     reference.Child(DBTable.Company.ToString()).Child(Parameters.responsibles.ToString()).Child(responsible.userID).Child(Parameters.servicesProvided.ToString()).RemoveValueAsync();
     reference.Child(DBTable.Responsible.ToString()).Child(responsible.userID).Child(Parameters.servicesProvided.ToString()).RemoveValueAsync().ContinueWith(task => {
         if (task.IsFaulted)
         {
             fail(task.Exception.ToString());
         }
         else if (task.IsCompleted)
         {
             responsible.servicesProvided.Clear();
             success();
         }
     });
 }
예제 #23
0
 public static void JustRemoveAppointmentWithouMessage(AppointmentModel appointment, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     FireBaseManager.GetFireBaseInstance().DeleteAppointment(appointment, success, fail);
 }
예제 #24
0
 public static void CreateNewAppointmentToCurrentUser(Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
 {
     CreateNewAppointment(currentUser, success, fail);
 }
예제 #25
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);
     });
 }
예제 #26
0
    public static void CreateNewMessageFromUserToResponsilbe(UserModel from, ResponsibleModel responsible, string message, string type, Delegates.GeneralListenerSuccess success, Delegates.GeneralListenerFail fail)
    {
        string companyID = "";
        var    mMessage  = new MessageModel(from.name, responsible.userID, message, DateTime.Now.ToString(Constants.dateformat), type);

        if (from.userType == Constants.UserType.User.ToString())
        {
            FireBaseManager.GetFireBaseInstance().CreateNewMessage(mMessage, from.userID, responsible.userID, responsible.companyID, delegate() {
                success();
            }, delegate(string error) {
                fail(error);
            });
        }
        else
        {
            fail("Usuário não é um profissional!");
        }
    }
예제 #27
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);
     });
 }
예제 #28
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!");
        }
    }