/// <summary>
        /// Gets the reference types.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public RefTypeResponse GetRefTypes(RefTypeRequest request)
        {
            var response = new RefTypeResponse();

            if (request.LoadOptions.Contains("RefTypes"))
            {
                response.RefTypes = RefTypeDao.GetRefTypes();
            }

            if (request.LoadOptions.Contains("RefTypeSearch"))
            {
                response.RefTypes = RefTypeDao.GetRefTypeSearch();
            }
            return(response);
        }
示例#2
0
        public RefTypeResponse InsertAccountDefaultConvert(RefTypeEntity refTypeEntity)
        {
            var response = new RefTypeResponse()
            {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                if (!refTypeEntity.Validate())
                {
                    foreach (string error in refTypeEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }

                var accountDefault = RefTypeDao.GetRefType(refTypeEntity.RefTypeId);
                if (accountDefault != null)
                {
                    if (accountDefault.RefTypeId == refTypeEntity.RefTypeId)
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        response.Message     = @"Tài khoản " + refTypeEntity.RefTypeName.Trim() + @" đã tồn tại !";
                        return(response);
                    }
                }
                response.Message = RefTypeDao.InsertReftype(refTypeEntity);
                if (!string.IsNullOrEmpty(response.Message))
                {
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                response.RefTypeId = refTypeEntity.RefTypeId;
                return(response);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                return(response);
            }
        }
示例#3
0
        public RefTypeResponse DeleteAccountDefault()
        {
            var response = new RefTypeResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                response.Message = RefTypeDao.DeleteRefTypeConvert();
                if (!string.IsNullOrEmpty(response.Message))
                {
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                return(response);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                return(response);
            }
        }
示例#4
0
        /// <summary>
        /// Updates the type of the reference.
        /// </summary>
        /// <param name="refTypeEntity">The reference type entity.</param>
        /// <returns></returns>
        public RefTypeResponse UpdateRefType(RefTypeEntity refTypeEntity)
        {
            var response = new RefTypeResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                if (!refTypeEntity.Validate())
                {
                    foreach (var error in refTypeEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                using (var scope = new TransactionScope())
                {
                    response.Message = RefTypeDao.UpdateRefType(refTypeEntity);
                    if (!string.IsNullOrEmpty(response.Message))
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        return(response);
                    }
                    scope.Complete();
                }
                response.RefTypeId = refTypeEntity.RefTypeId;
                return(response);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                return(response);
            }
        }