Exemple #1
0
        public int SincronizeDepartmentWithBitrix()
        {
            Bitrix24Services _serviceBitrix  = new Bitrix24Services();
            WebhookServices  _serviceWebhook = new WebhookServices();

            try
            {
                IList <Webhook> lstWebhook = _serviceWebhook.GetWebhooks();
                DeleteAllDepartments();

                foreach (Webhook webhook in lstWebhook)
                {
                    IList <Department> lstDepartment = _serviceBitrix.GetDepartments(webhook.WebhookPath);

                    foreach (Department department in lstDepartment)
                    {
                        if (GetDepartmentsById(department.DepartmentId) == null)
                        {
                            department.WebhookId = webhook.WebhookID;
                            _departmentRepository.Add(department);
                        }
                    }
                }
                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Exemple #2
0
        public int SincronizeAttendantWithBitrix()
        {
            Bitrix24Services   _serviceBitrix     = new Bitrix24Services();
            WebhookServices    _serviceWebhook    = new WebhookServices();
            DepartmentServices _serviceDepartment = new DepartmentServices();

            try
            {
                IList <Webhook> lstWebhook = _serviceWebhook.GetWebhooks();
                DeleteAllAttendants();

                foreach (Webhook webhook in lstWebhook)
                {
                    IList <Department> lstDepartment = _serviceBitrix.GetDepartments(webhook.WebhookPath);

                    foreach (Department departItem in lstDepartment)
                    {
                        IList <Attendant> lstAttendant = _serviceBitrix.GetEmployeeDepartments(webhook.WebhookPath,
                                                                                               departItem.DepartmentId);

                        foreach (Attendant attendants in lstAttendant)
                        {
                            if (GetAttendantsByID(attendants.AttendantId).Count == 0)
                            {
                                _attendantRepository.Add(attendants);
                            }
                        }
                    }
                }
                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }