public List <AccountPerson> GetEmployeeListByAccount(Account account)
        {
            if (account == null)
            {
                throw new ArgumentNullException(nameof(account));
            }

            return(ExecuteFaultHandledOperation(() =>
            {
                var employees = new List <AccountPerson>();
                var acct = new AccountData()
                {
                    AccountKey = account.AccountKey
                };

                var emps_data = _entity_person_repo.GetAll(acct);

                foreach (EntityPersonData emp_data in emps_data)
                {
                    Log.Debug("EntityPersonKey {0}", emp_data.EntityPersonKey);
                    AccountPerson employee = _acct_es.Map(emp_data);
                    //employee.PersonAttributes = entity_attrib_be.GetAttributeByEntity(employee.PersonKey, QIQOEntityType.Person);
                    //employee.Addresses = address_be.GetAddressesByEntityID(employee.PersonKey, QIQOEntityType.Person);

                    PersonData ent_per = _person_repo.GetByID(employee.PersonKey);
                    _pers_es.InitPersonData(employee, ent_per);

                    Log.Info($"Employee: {employee.PersonLastName}; Role: {employee.RoleInCompany}; Type: {employee.CompanyRoleType}; EntityPersonKey {employee.EntityPersonKey}");

                    employees.Add(employee);
                }
                return employees;
            }));
        }
Ejemplo n.º 2
0
        public bool AccountDelete(Account account)
        {
            return(ExecuteFaultHandledOperation(() =>
            {
                var acct = _acct_es.Map(account);

                if (account.Addresses != null)
                {
                    Log.Info($"Account addresses to be deleted -> {account.Addresses.Count}");
                    foreach (Address address in account.Addresses)
                    {
                        try
                        {
                            bool ret_value = _address_be.AddressDelete(address);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error deleting account address data from the database");
                            Log.Error($"{ex.Source}:{ex.Message}");
                            throw ex;
                        }
                    }
                }

                if (account.AccountAttributes != null)
                {
                    Log.Info($"Account attributes to be deleted -> {account.AccountAttributes.Count}");
                    foreach (EntityAttribute attribute in account.AccountAttributes)
                    {
                        try
                        {
                            bool ret_value = _entity_attribute_be.EntityAttributeDelete(attribute);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error deleting account attribute data from the database");
                            Log.Error($"{ex.Source}:{ex.Message}");
                            throw ex;
                        }
                    }
                }

                if (account.FeeSchedules != null)
                {
                    Log.Info($"Account fee schedule to be deleted -> {account.FeeSchedules.Count}");
                    foreach (FeeSchedule fee_schedule in account.FeeSchedules)
                    {
                        try
                        {
                            bool ret_value = _fee_schedule_be.FeeScheduleDelete(fee_schedule);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error deleting account fee schedule data from the database");
                            Log.Error($"{ex.Source}:{ex.Message}");
                            throw ex;
                        }
                    }
                }

                if (account.Employees != null)
                {
                    Log.Info($"Account employee(s) to be deleted -> {account.FeeSchedules.Count}");
                    foreach (AccountPerson employee in account.Employees)
                    {
                        try
                        {
                            bool ret_value = _account_employee_be.EmployeeDelete(account, employee);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error deleting account employee data from the database");
                            Log.Error($"{ex.Source}:{ex.Message}");
                            throw ex;
                        }
                    }
                }

                if (account.Contacts != null)
                {
                    Log.Info($"Account contact(s) to be deleted -> {account.Contacts.Count}");
                    foreach (Contact contact in account.Contacts)
                    {
                        try
                        {
                            bool ret_value = _contact_be.ContactDelete(contact);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error deleting account contact data from the database");
                            Log.Error($"{ex.Source}:{ex.Message}");
                            throw ex;
                        }
                    }
                }

                if (account.Comments != null)
                {
                    Log.Info($"Account comment(s) to be deleted -> {account.Comments.Count}");
                    foreach (var comment in account.Comments)
                    {
                        try
                        {
                            bool ret_value = _comment_be.CommentDelete(comment);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error deleting account comment data from the database");
                            Log.Error($"{ex.Source}:{ex.Message}");
                            throw ex;
                        }
                    }
                }

                _acct_repo.Delete(acct);
                return true;
            }));
        }
Ejemplo n.º 3
0
 public void SaveAccount(Account account)
 {
     ExecuteHandledOperation(() => { _accountRepository.Save(_accountEntityService.Map(account)); });
 }
 public List <FeeSchedule> GetFeeSchedulesByAccount(Account account)
 {
     return(ExecuteHandledOperation(() => { return _feeScheduleEntityService.Map(_feeScheduleRepository.GetAll(_accountEntityService.Map(account))); }));
 }
Ejemplo n.º 5
0
 public Task <List <Account> > GetAccountsAsync()
 {
     return(Task.Factory.StartNew(() => {
         return _accountEntityService.Map(_accountRepository.GetAll());
     }));
 }