public static int Create(UserCommentParameter param) { using (var db = new MsSql(DbName.Official)) { return(db.Write( CommandType.Text, "INSERT INTO [dbo].[UserComment]([Name],[Title],[Comment],[ImgPath],[CreateTime])VALUES(@Name,@Title,@Comment,@ImgPath,GETUTCDATE());", new DbParameter[] { new SqlParameter { Value = param.Entity.Name, SqlDbType = SqlDbType.NVarChar, ParameterName = "@Name", Direction = ParameterDirection.Input }, new SqlParameter { Value = param.Entity.Title, SqlDbType = SqlDbType.NVarChar, ParameterName = "@Title", Direction = ParameterDirection.Input }, new SqlParameter { Value = param.Entity.Comment, SqlDbType = SqlDbType.NVarChar, ParameterName = "@Comment", Direction = ParameterDirection.Input }, new SqlParameter { Value = param.Entity.ImgPath, SqlDbType = SqlDbType.NVarChar, ParameterName = "@ImgPath", Direction = ParameterDirection.Input } })); } }
public ActionResult AjaxUserCommentDeleteFile(UserCommentParameter param) { var result = new JsonNetResult(); Io.DeleteFile(HttpContext.Server.MapPath($"~{param.Entity.ImgPath}")); result.Data = new { Ststus = "OK" }; return(result); }
/// <summary> /// 用戶感言 清單頁 /// </summary> /// <param name="param"></param> /// <returns></returns> public ActionResult UserComments(UserCommentParameter param) { param.KeyWord = HttpUtility.UrlDecode(param.KeyWord); return(View( new InternalDataTransferToView { List = UserCommentTableProvider.List(param), Data = param })); }
public ActionResult UserCommentEdit(UserCommentParameter param) { if (0L < param.Entity.UserCommentId) { param.Entity = UserCommentTableProvider.Detail(param); } return(View(new InternalDataTransferToView { Data = param })); }
public static int Delete(UserCommentParameter param) { using (var db = new MsSql(DbName.Official)) { return(db.Write(CommandType.Text, "DELETE FROM [dbo].[UserComment] WHERE [UserCommentId] = @UserCommentId;", new DbParameter[] { new SqlParameter { Value = param.Entity.UserCommentId, SqlDbType = SqlDbType.Int, ParameterName = "@UserCommentId", Direction = ParameterDirection.Input } })); } }
public ActionResult AjaxUserCommentEdit(UserCommentParameter param) { var result = new JsonNetResult(); var r = new GeneralResponse(); try { r.Code = (0L < param.Entity.UserCommentId ? UserCommentTableProvider.Update(param) : UserCommentTableProvider.Create(param)).ToString(Section.Get.Common.Culture); } catch (Exception ex) { Log.Error(ex.Message, ex); r.Code = "-11" + ex.Message; } result.Data = r; return(result); }
public static UserComment Detail(UserCommentParameter param) { using (var db = new MsSql(DbName.Official)) { var data = new UserComment(); data.Fill( db.First( CommandType.Text, "SELECT [UserCommentId],[Name],[Title],[Comment],[ImgPath],[CreateTime] FROM [dbo].[UserComment] WITH(READUNCOMMITTED) WHERE [UserCommentId] = @UserCommentId;", new DbParameter[] { new SqlParameter { Value = param.Entity.UserCommentId, SqlDbType = SqlDbType.Int, ParameterName = "@UserCommentId", Direction = ParameterDirection.Input } })); return(data); } }
public ActionResult AjaxUserCommentDelete(UserCommentParameter param) { var result = new JsonNetResult(); var r = new GeneralResponse(); try { var detail = UserCommentTableProvider.Detail(param); r.Code = UserCommentTableProvider.Delete(param).ToString(Section.Get.Common.Culture); if (!string.IsNullOrEmpty(detail.ImgPath)) { Io.DeleteFile(System.Web.HttpContext.Current.Server.MapPath($"~{detail.ImgPath}")); } } catch (Exception ex) { Log.Error(ex.Message, ex); r.Code = "-11"; } result.Data = r; return(result); }
//Update public static int Update(UserCommentParameter param) { using (var db = new MsSql(DbName.Official)) { return(db.Write( CommandType.Text, "UPDATE [dbo].[UserComment] SET [Name] = @Name,[Title] = @Title,[ImgPath] = @ImgPath,[Comment] = @Comment WHERE [UserCommentId] = @UserCommentId;", new DbParameter[] { new SqlParameter { Value = param.Entity.UserCommentId, SqlDbType = SqlDbType.Int, ParameterName = "@UserCommentId", Direction = ParameterDirection.Input }, new SqlParameter { Value = param.Entity.Name, SqlDbType = SqlDbType.NVarChar, ParameterName = "@Name", Direction = ParameterDirection.Input }, new SqlParameter { Value = param.Entity.Title, SqlDbType = SqlDbType.NVarChar, ParameterName = "@Title", Direction = ParameterDirection.Input }, new SqlParameter { Value = param.Entity.Comment, SqlDbType = SqlDbType.NVarChar, ParameterName = "@Comment", Direction = ParameterDirection.Input }, new SqlParameter { Value = param.Entity.ImgPath, SqlDbType = SqlDbType.NVarChar, ParameterName = "@ImgPath", Direction = ParameterDirection.Input } })); } }
public static DataSet List(UserCommentParameter param) { using (var db = new MsSql(DbName.Official)) { return(db.DataSet( CommandType.StoredProcedure, "[dbo].[sp_FrontFetchUserCommentList_Sel]", new DbParameter[] { new SqlParameter { Value = param.KeyWord, SqlDbType = SqlDbType.NVarChar, ParameterName = "@argStrKeyWord", Direction = ParameterDirection.Input }, new SqlParameter { Value = string.IsNullOrEmpty(param.StartUtcDateTime)?null:param.StartUtcDateTime, SqlDbType = SqlDbType.DateTime, ParameterName = "@argDteStart", Direction = ParameterDirection.Input }, new SqlParameter { Value = string.IsNullOrEmpty(param.EndUtcDateTime)?null:param.EndUtcDateTime, SqlDbType = SqlDbType.DateTime, ParameterName = "@argDteEnd", Direction = ParameterDirection.Input }, new SqlParameter { Value = param.Page, SqlDbType = SqlDbType.Int, ParameterName = "@argIntPage", Direction = ParameterDirection.Input }, new SqlParameter { Value = param.PageSize, SqlDbType = SqlDbType.Int, ParameterName = "@argIntPageSize", Direction = ParameterDirection.Input } })); } }