Ejemplo n.º 1
0
        /// <summary>
        /// 添加用户意见反馈
        /// </summary>
        public ServiceInvokeDTO AddFeedBack(Feedback feedback)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO result = null;

            try
            {
                // 验证参数
                FeedbackValidator validator = new FeedbackValidator();
                ValidationResult validatorResult = validator.Validate(feedback);
                if (validatorResult.IsValid)
                {
                    feedBackDAL.Insert(feedback);
                    result = new ServiceInvokeDTO(InvokeCode.SYS_INVOKE_SUCCESS);
                }
                else
                {
                    result = new ServiceInvokeDTO(InvokeCode.SYS_ARG_ERROR);
                    log.Error(string.Format(Constant.DEBUG_ARG_ERROR_FORMATER, validatorResult.Errors[0].ErrorMessage));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加实体对象,返回插入成功后的实体对象主键ID
        /// </summary>
        public int Insert(Feedback feedback)
        {
            const string sql = @"INSERT INTO Feedback(Content, Contact, TerminalType) VALUES (@Content, @Contact, @TerminalType);
                               SELECT LAST_INSERT_ID();";

            int id = 0;
            using (DbConnection connection = ConnectionManager.OpenConnection)
            {
                id = connection.Query<int>(sql, feedback).SingleOrDefault<int>();
            }
            return id;
        }