Пример #1
0
        public bool EmployeeDelete(Employee employee)
        {
            if (employee == null)
            {
                throw new ArgumentNullException(nameof(employee));
            }

            return(ExecuteFaultHandledOperation(() =>
            {
                var person = _pers_es.Map(employee);
                person.PersonKey = employee.PersonKey;

                if (employee.Addresses != null)
                {
                    Log.Info($"Employee addresses to be saved -> {employee.Addresses.Count}");
                    foreach (Address address in employee.Addresses)
                    {
                        _address_be.AddressDelete(address);
                    }
                }

                if (employee.PersonAttributes != null)
                {
                    Log.Info($"Employee attributes to be saved -> {employee.PersonAttributes.Count}");
                    foreach (EntityAttribute attribute in employee.PersonAttributes)
                    {
                        _entity_attrib_be.EntityAttributeDelete(attribute);
                    }
                }

                _person_repo.Delete(person);
                Log.Info($"Employee [{person.PersonKey}] deleted from the database sucessfully!");
                return true;
            }));
        }
Пример #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;
            }));
        }
        public bool DeleteAddress(Address address)
        {
            IAddressBusinessEngine address_be = _business_engine_factory.GetBusinessEngine <IAddressBusinessEngine>();

            return(address_be.AddressDelete(address));
        }