public AdminCommentObject Save(AdminCommentObject adminComment) { if (adminComment.AdminCommentId > 0) // Update { string sql = @" UPDATE dat_AdminComment SET Comment = @Comment, AdminOnly = @AdminOnly, Deleted = @Deleted, DeleteEmployeeId = @DeleteEmployeeId WHERE AdminCommentId = @AdminCommentId"; Config.Conn.Execute(sql, adminComment); } else { string sql = @" INSERT INTO dat_AdminComment ( MainId, EmployeeId, Comment, AdminOnly ) VALUES ( @MainId, @EmployeeId, @Comment, @AdminOnly ) SELECT CAST(SCOPE_IDENTITY() AS INT)"; adminComment.AdminCommentId = Config.Conn.Query <int>(sql, adminComment).Single(); } return(adminComment); }
public static int Add(int mainId, string comment, bool adminOnly) { var c = new AdminCommentObject { MainId = mainId, EmployeeId = UserObject.CurrentUser.EmployeeId, Comment = comment, AdminOnly = adminOnly }; c.Save(); return(c.AdminCommentId); }