/// <summary> /// 详情 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Info(int id) { E_CommentType model = new E_CommentType(); model.commenttypeid = id; ViewBag.Info = dal.GetInfoById(model); return(View()); }
/// <summary> /// 保存 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Save(E_CommentType model) { if (model != null && model.commenttypeid > 0) { return(dal.Update(model)); } return(dal.Add(model)); }
/// <summary> /// 查询 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="model"></param> /// <returns></returns> public E_CommentType GetInfoById(E_CommentType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from dp_commenttype where commenttypeid=@commenttypeid"); using (IDbConnection conn = new SqlConnection(DapperHelper.GetConStr())) { model = conn.Query <E_CommentType>(strSql.ToString(), model)?.FirstOrDefault(); } return(model); }
/// <summary> /// 添加 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Add(E_CommentType model) { string sql = "INSERT INTO dp_commenttype([typename]) VALUES (@typename)"; using (IDbConnection conn = new SqlConnection(DapperHelper.GetConStr())) { int count = conn.Execute(sql, model); if (count > 0)//如果更新失败 { return(true); } else { return(false); } } }
/// <summary> /// 查询某主题下的点评维度 /// </summary> /// <param name="model"></param> /// <returns></returns> public List <E_CommentType> GetListByThemeid(E_CommentType model) { List <E_CommentType> list; StringBuilder strSql = new StringBuilder(); strSql.Append(@"select * from dp_commenttype where commenttypeid in ( select commenttypeid from ( select * from dp_themecommentitem where themeid=@themeid ) as A inner join dp_commentitem as B on A.commentitemid=B.commentitemid group by commenttypeid ) and isdelete=0"); using (IDbConnection conn = new SqlConnection(DapperHelper.GetConStr())) { list = conn.Query <E_CommentType>(strSql.ToString(), model)?.ToList(); } return(list); }
/// <summary> /// 删除 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool DeleteById(E_CommentType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update dp_commenttype set isdelete=1 where commenttypeid=@commenttypeid "); using (IDbConnection conn = new SqlConnection(DapperHelper.GetConStr())) { int count = conn.Execute(strSql.ToString(), model); if (count > 0)//如果更新失败 { return(true); } else { return(false); } } }
/// <summary> /// 删除 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Delete(E_CommentType model) { return(dal.DeleteById(model)); }