Пример #1
0
        public int Delete(int nokID, int personID, out Int64 mainDBTimeStamp)
        {
            mainDBTimeStamp = 0;
            try
            {
                int    result     = 0;
                string userName   = IdentityUser.GetIdentityUserName();
                int    categoryID = _categoryDA.GetCategoryIDByCategoryKey((int)CategoryPersonKeyEnum.NOK);
                if (categoryID <= 0)
                {
                    throw new Exception(Properties.Resources.ERROR_NoCategoryDefinedForNOKs);
                }

                using (TransactionScope scope = new TransactionScope())
                {
                    //_customerDA.Update(customerID, userName);
                    //mainDBTimeStamp = _customerDA.GetDBTimeStamp(customerID);
                    result = _nokDA.Delete(nokID);
                    if (_nokDA.GetNOKsFromPerson(personID) == 0)
                    {
                        _personCatRelDA.Delete(personID, categoryID);
                    }
                    scope.Complete();
                }
                return(result);
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, ExceptionPolicies.Service))
                {
                    throw;
                }
                return(0);
            }
        }
        public int Delete(int customerContactPersonID, int personID)
        {
            try
            {
                int result     = 0;
                int categoryID = _categoryDA.GetCategoryIDByCategoryKey((int)CategoryPersonKeyEnum.CustContactPerson);
                if (categoryID <= 0)
                {
                    throw new Exception(Properties.Resources.ERROR_NoCategoryDefinedForCCPs);
                }

                using (TransactionScope scope = new TransactionScope())
                {
                    result = _customerContactPersonDA.Delete(customerContactPersonID);
                    if (_customerContactPersonDA.GetCustomerContactPersonsFromPerson(personID) == 0)
                    {
                        _personCatRelDA.Delete(personID, categoryID);
                    }
                    scope.Complete();
                }
                return(result);
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, ExceptionPolicies.Service))
                {
                    throw;
                }
                return(0);
            }
        }