/// <summary>
        /// Sets the automatic businesses.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public AutoNumberResponse SetAutoNumbers(AutoNumberRequest request)
        {
            var response = new AutoNumberResponse();

            var autoNumberEntity = request.AutoNumber;

            if (request.Action != PersistType.Delete && autoNumberEntity != null)
            {
                if (!autoNumberEntity.Validate())
                {
                    foreach (var error in autoNumberEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
            }
            try
            {
                if (request.Action == PersistType.Update)
                {
                    if (request.AutoNumbers != null && request.AutoNumbers.Count > 0)
                    {
                        foreach (var autoNumber in request.AutoNumbers)
                        {
                            if (!autoNumber.Validate())
                            {
                                foreach (var error in autoNumber.ValidationErrors)
                                {
                                    response.Message += error + Environment.NewLine;
                                }
                                response.Acknowledge = AcknowledgeType.Failure;
                                return(response);
                            }
                            response.Message = AutoNumberDao.UpdateAutoNumber(autoNumber);
                            if (response.Message == null)
                            {
                                continue;
                            }
                            response.Acknowledge = AcknowledgeType.Failure;
                            return(response);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response.Acknowledge = AcknowledgeType.Failure;
                response.Message     = ex.Message;
                return(response);
            }

            return(response);
        }
        /// <summary>
        /// Gets the automatic numbers.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public AutoNumberResponse GetAutoNumbers(AutoNumberRequest request)
        {
            var response = new AutoNumberResponse();

            if (request.LoadOptions.Contains("AutoNumber"))
            {
                if (request.LoadOptions.Contains("RefType"))
                {
                    response.AutoNumber = AutoNumberDao.GetAutoNumberByRefType(request.RefTypeId);
                }
            }
            if (request.LoadOptions.Contains("AutoNumbers"))
            {
                response.AutoNumbers = AutoNumberDao.GetAutoNumbers();
            }

            return(response);
        }