public void DeleteByPageId(int pageId) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.Bullet_DeleteByPageId; command.Parameters.Add(new SqlParameter("@pageId", pageId)); connection.Open(); command.ExecuteNonQuery(); } }
public int Read(string name) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.Configuration_Read; command.Parameters.Add(new SqlParameter("@name", name)); connection.Open(); var result = command.ExecuteScalar(); return((int)result); } }
public void Create(Bullet bullet) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.Bullet_Create; AddParameters(bullet, command); connection.Open(); bullet.Id = (int)command.ExecuteScalar(); } }
public void Create(UserPageSettings userPageSettings) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.UserPageSettings_Create; AddParameters(userPageSettings, command); connection.Open(); userPageSettings.Id = (int)command.ExecuteScalar(); } }
public void Update(string name, int value) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.Configuration_Update; command.Parameters.Add(new SqlParameter("@name", name)); command.Parameters.Add(new SqlParameter("@value", value)); connection.Open(); command.ExecuteNonQuery(); } }
public void Create(DocumentationPage page) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.DocumentationPage_Create; AddParameters(page, command); connection.Open(); page.Id = (int)command.ExecuteScalar(); } }
private void MatchUrls_DeleteByHelpId(int helpId) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.PageUrl_DeleteByPageId; command.Parameters.Add(new SqlParameter("@pageId", helpId)); connection.Open(); command.ExecuteNonQuery(); } }
public void Delete(int id) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.DocumentationPage_Delete; command.Parameters.Add(new SqlParameter("@id", id)); connection.Open(); command.ExecuteNonQuery(); } }
public void Update(Bullet bullet) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.Bullet_Update; AddParameters(bullet, command); command.Parameters.Add(new SqlParameter("@id", bullet.Id)); connection.Open(); command.ExecuteNonQuery(); } }
public void Update(UserPageSettings userPageSettings) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.UserPageSettings_Update; AddParameters(userPageSettings, command); command.Parameters.Add(new SqlParameter("@id", userPageSettings.Id)); connection.Open(); command.ExecuteNonQuery(); } }
public void Update(DocumentationPage page) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.DocumentationPage_Update; AddParameters(page, command); command.Parameters.Add(new SqlParameter("@id", page.Id)); connection.Open(); command.ExecuteNonQuery(); } }
public void Delete(int id) { MatchUrls_DeleteByHelpId(id); using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.FirstTimeHelp_Delete; command.Parameters.Add(new SqlParameter("@id", id)); connection.Open(); command.ExecuteNonQuery(); } }
public void Create(FirstTimeHelp help) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.FirstTimeHelp_Create; AddParameters(help, command); connection.Open(); help.Id = (int)command.ExecuteScalar(); } MatchUrls_CreateByHelpId(help.Id, help.MatchUrls); }
public IEnumerable <Bullet> ReadAll() { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.Bullet_ReadAll; connection.Open(); var reader = command.ExecuteReader(); foreach (var bullet in HydrateBullets(reader)) { yield return(bullet); } } }
public IEnumerable <FirstTimeHelp> ReadAll() { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.FirstTimeHelp_ReadAll; connection.Open(); var reader = command.ExecuteReader(); foreach (var help in HydratePages(reader)) { yield return(help); } } }
public IEnumerable <DocumentationPage> ReadAll() { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.DocumentationPage_ReadAll; connection.Open(); var reader = command.ExecuteReader(); foreach (var page in HydratePages(reader)) { yield return(page); } } }
public void Update(FirstTimeHelp help) { using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.FirstTimeHelp_Update; AddParameters(help, command); command.Parameters.Add(new SqlParameter("@id", help.Id)); connection.Open(); command.ExecuteNonQuery(); } MatchUrls_DeleteByHelpId(help.Id); MatchUrls_CreateByHelpId(help.Id, help.MatchUrls); }
public void DeleteExcept(List <int> pageIds) { if (null == pageIds || pageIds.Count == 0) { return; } using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.DocumentationPage_DeleteExcept.Replace("@pageIds", pageIds.ToCsv()); connection.Open(); command.ExecuteNonQuery(); } }
public FirstTimeHelp ReadByUrl(string url) { FirstTimeHelp result = null; using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.FirstTimeHelp_ReadByUrl; command.Parameters.Add(new SqlParameter("@url", url)); connection.Open(); using (var reader = command.ExecuteReader()) { result = HydratePages(reader).FirstOrDefault(); } } return(result); }
public List <Bullet> ReadByPageId(int pageId) { List <Bullet> result; using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.Bullet_ReadByPageId; command.Parameters.Add(new SqlParameter("@pageId", pageId)); connection.Open(); using (var reader = command.ExecuteReader()) { result = new List <Bullet>(HydrateBullets(reader)); } } return(result); }
public List <DocumentationPage> ReadByParentId(int?parentId) { List <DocumentationPage> result = null; using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.DocumentationPage_ReadByParentId; command.Parameters.Add(new SqlParameter("@parentId", (object)parentId ?? DBNull.Value)); connection.Open(); using (var reader = command.ExecuteReader()) { result = new List <DocumentationPage>(HydratePages(reader)); } } return(result ?? new List <DocumentationPage>()); }
public DocumentationPage Read(int id) { DocumentationPage result = null; using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.DocumentationPage_ReadById; command.Parameters.Add(new SqlParameter("@id", id)); connection.Open(); using (var reader = command.ExecuteReader()) { result = HydratePages(reader).FirstOrDefault(); } } return(result); }
public UserPageSettings Read(string userName, int pageId) { UserPageSettings result = null; using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.UserPageSettings_ReadByUserAndPage; command.Parameters.AddRange(new SqlParameter[] { new SqlParameter("@userName", userName), new SqlParameter("@pageId", pageId) }); connection.Open(); using (var reader = command.ExecuteReader()) { result = HydrateUserPageSettings(reader).FirstOrDefault(); } } return(result); }
private void MatchUrls_CreateByHelpId(int helpId, string matchUrls) { if (!string.IsNullOrEmpty(matchUrls)) { var pageUrls = matchUrls.Trim().Split(' '); using (var connection = SqlConnectionFactory.GetConnection()) { connection.Open(); foreach (var pageUrl in pageUrls) { using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.PageUrl_Create; command.Parameters.Add(new SqlParameter("@url", pageUrl.Replace('*', '%'))); command.Parameters.Add(new SqlParameter("@pageId", helpId)); command.ExecuteNonQuery(); } } } } }
public List <DocumentationPage> ReadTableOfContents(bool includeHidden) { var result = new List <DocumentationPage>(); using (var connection = SqlConnectionFactory.GetConnection()) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = SqlScripts.DocumentationPage_ReadTableOfContents; command.Parameters.Add(new SqlParameter("@includeHidden", includeHidden)); connection.Open(); using (var reader = command.ExecuteReader()) { var idOrdinal = reader.GetOrdinal("Id"); var parentPageIdOrdinal = reader.GetOrdinal("ParentPageId"); var orderOrdinal = reader.GetOrdinal("Order"); var titleOrdinal = reader.GetOrdinal("Title"); var isHiddenOrdinal = reader.GetOrdinal("IsHidden"); while (reader.Read()) { result.Add(new DocumentationPage { Id = reader.GetInt32(idOrdinal), ParentPageId = reader.IsDBNull(parentPageIdOrdinal) ? (int?)null : reader.GetInt32(parentPageIdOrdinal), Order = reader.GetInt32(orderOrdinal), Title = reader.GetString(titleOrdinal), IsHidden = reader.GetBoolean(isHiddenOrdinal), }); } } } return(result); }