public bool Update(SystemFeedback model, List <string> fileds, string sqlWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.AppendFormat("update {0} set ", model.GetType().Name);
            List <string>       filedsList   = new List <string>();
            List <SqlParameter> sqlParameter = new List <SqlParameter>();
            SqlParameter        Param        = new SqlParameter("@Id", SqlDbType.Int, 4);

            if (string.IsNullOrEmpty(sqlWhere))
            {
                Param.Value = model.Id;
                sqlParameter.Add(Param);
            }
            foreach (string filed in fileds)
            {
                filedsList.Add(string.Format("{0}=@{0}", filed));
                Param = new SqlParameter(string.Format("@{0}", filed), model.GetType().GetProperty(filed).GetValue(model, null));
                sqlParameter.Add(Param);
            }
            strSql.AppendFormat("{0}", string.Join(",", filedsList.ToArray()));
            if (string.IsNullOrEmpty(sqlWhere))
            {
                strSql.Append(" where Id=@Id ");
            }
            else
            {
                strSql.AppendFormat(" where 1=1 and {0} ", sqlWhere);
            }
            SqlParameter[] parameters = sqlParameter.ToArray();
            return(sqlhelper.ExecNon(strSql.ToString(), parameters) > 0 ? true : false);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserFullName,UserEmail,Message,SystemFeedbackCategoryId")] SystemFeedback systemFeedback)
        {
            if (id != systemFeedback.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(systemFeedback);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SystemFeedbackExists(systemFeedback.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SystemFeedbackCategoryId"] = new SelectList(_context.SystemFeedbackCategories, "Id", "Id", systemFeedback.SystemFeedbackCategoryId);
            return(View(systemFeedback));
        }
        public async Task <IActionResult> Create([Bind("Id,UserFullName,UserEmail,Message,SystemFeedbackCategoryId")] SystemFeedback systemFeedback)
        {
            if (ModelState.IsValid)
            {
                _context.Add(systemFeedback);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SystemFeedbackCategoryId"] = new SelectList(_context.SystemFeedbackCategories, "Id", "Id", systemFeedback.SystemFeedbackCategoryId);
            return(View(systemFeedback));
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SystemFeedback GetModel(string where)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, UserId, UserName, FeedbackContet, FeedbackTime  ");
            strSql.Append("  from SystemFeedback ");
            strSql.Append(" where ");
            strSql.Append(where);

            var            dt    = sqlhelper.GetTable(strSql.ToString());
            SystemFeedback model = null;

            if (dt.Rows.Count > 0)
            {
                model = Mapper.DynamicMap <IDataReader, List <SystemFeedback> >(dt.CreateDataReader()).FirstOrDefault();
            }
            return(model);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SystemFeedback model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SystemFeedback(");
            strSql.Append("UserId,UserName,FeedbackContet,FeedbackTime");
            strSql.Append(") values (");
            strSql.Append("@UserId,@UserName,@FeedbackContet,@FeedbackTime");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",         SqlDbType.Int,        4),
                new SqlParameter("@UserName",       SqlDbType.VarChar,   50),
                new SqlParameter("@FeedbackContet", SqlDbType.VarChar, 1000),
                new SqlParameter("@FeedbackTime",   SqlDbType.DateTime)
            };

            parameters[0].Value = model.UserId;
            parameters[1].Value = model.UserName;
            parameters[2].Value = model.FeedbackContet;
            parameters[3].Value = model.FeedbackTime;
            return(sqlhelper.ExecNon(strSql.ToString(), parameters));
        }