public void Add() { using (SqlCmd cmd = new SqlCmd("INSERT INTO LogHistory (UserId, [Type], ActionType, PreviousChange, NewChange) VALUES (@UserId, @Type, @Action, @Previous, @New)", false)) { cmd.AddIInt("@UserId", UserId); cmd.AddIInt("@Type", (int)Type); cmd.AddIInt("@Action", (int)Action); cmd.AddIString("@Previous", -1, PreviousChange); cmd.AddIString("@New", -1, NewChange); cmd.Execute(); } }
public static void Activate(int id) { using (SqlCmd cmd = new SqlCmd("UPDATE [User] SET IsActive = 1, EmailConfirmation = NULL WHERE Id = @Id", false)) { cmd.AddIInt("@Id", id); cmd.Execute(); } }
public static DataTable ListCultural(int id) { using (SqlCmd cmd = new SqlCmd("SELECT CulturalText FROM Cultural WHERE EpisodeId = @Id", false)) { cmd.AddIInt("@Id", id); return(cmd.ExecuteTable()); } }
public static DataTable ListNotes(int id) { using (SqlCmd cmd = new SqlCmd("SELECT Note FROM Notes WHERE EpisodeId = @Id", false)) { cmd.AddIInt("@Id", id); return(cmd.ExecuteTable()); } }
public static void UpdatePassword(int userId, string hash) { using (SqlCmd cmd = new SqlCmd("UPDATE [User] SET UserPassword = @Hash WHERE Id = @UserId; UPDATE ResetRequests SET PasswordReset = 1 WHERE UserId = @UserId;", false)) { cmd.AddIInt("@UserId", userId); cmd.AddIString("@Hash", 250, hash); cmd.Execute(); } }
public static void AssignEmailConfirmation(int userId, Guid?emailConfirmation, bool isActive = false) { using (SqlCmd cmd = new SqlCmd("UPDATE [User] SET EmailConfirmation = @EmailConfirmation, IsActive = @IsActive WHERE Id = @Id", false)) { cmd.AddIInt("@Id", userId); cmd.AddIGuid("@EmailConfirmation", emailConfirmation); cmd.AddIBool("@IsActive", isActive); cmd.Execute(); } }
public void Set() { using (SqlCmd cmd = new SqlCmd("UPDATE ContentPage SET [Name] = @Name, [Path] = @Path, Content = @Content WHERE Id = @Id", false)) { cmd.AddIInt("@Id", Id); cmd.AddIString("@Name", 100, Name); cmd.AddIString("@Path", 100, Path); cmd.AddIString("@Content", -1, Content); cmd.Execute(); } }
public static void AddResetRequest(Guid id, int userId) { using (SqlCmd cmd = new SqlCmd("UPDATE ResetRequests SET PasswordReset = 1 WHERE UserId = @UserId", false)) { cmd.AddIInt("@UserId", userId); cmd.Execute(); } using (SqlCmd cmd = new SqlCmd("INSERT INTO ResetRequests (Id, UserId) VALUES (@Id, @UserId)", false)) { cmd.AddIGuid("@Id", id); cmd.AddIInt("@UserId", userId); cmd.Execute(); } }
public void Set() { using (SqlCmd cmd = new SqlCmd("UPDATE Article SET Title = @Title, SubHeading = @SubHeading, ShortDescription = @ShortDescription, Content = @Content, PublishDate = @PublishDate, UrlLabel = @UrlLabel WHERE Id = @Id", false)) { cmd.AddIInt("@Id", Id); cmd.AddIString("@Title", 300, Title); cmd.AddIString("@SubHeading", 300, SubHeading); cmd.AddIString("@ShortDescription", 1000, ShortDescription); cmd.AddIString("@Content", -1, Content); cmd.AddIDateTime("@PublishDate", PublishDate); cmd.AddIString("@UrlLabel", 300, CreateUrl()); cmd.Execute(); } }
public void Add() { using (SqlCmd cmd = new SqlCmd("INSERT INTO Article VALUES (@UserId, @Title, @SubHeading, @ShortDescription, @Content, @PublishDate, @UrlLabel); SET @Id = SCOPE_IDENTITY();", false)) { cmd.AddIInt("@UserId", Author.Id); cmd.AddIString("@Title", 300, Title); cmd.AddIString("@SubHeading", 300, SubHeading); cmd.AddIString("@ShortDescription", 1000, ShortDescription); cmd.AddIString("@Content", -1, Content); cmd.AddIDateTime("@PublishDate", PublishDate); cmd.AddIString("@UrlLabel", 300, CreateUrl()); cmd.AddOInt("@Id"); cmd.Execute(); Id = cmd.GetInt("@Id"); } }
public static string GetUrl(int id) { DataRow r; using (SqlCmd cmd = new SqlCmd("SELECT UrlLabel FROM Episode WHERE Id = @Id", false)) { cmd.AddIInt("@Id", id); r = cmd.ExecuteSingleRowOrNull(); } if (r == null) { return(""); } return(r["UrlLabel"].ToString()); }
public static ContentPage Get(int id) { DataRow r; using (SqlCmd cmd = new SqlCmd("SELECT * FROM ContentPage WHERE Id = @Id", false)) { cmd.AddIInt("@Id", id); r = cmd.ExecuteSingleRowOrNull(); } if (r == null) { return(null); } return(new ContentPage { Id = (int)r["Id"], Name = (string)r["Name"], Path = (string)r["Path"], Content = (string)r["Content"] }); }