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 void Activate(Guid confirmation) { using (SqlCmd cmd = new SqlCmd("UPDATE [User] SET IsActive = 1, EmailConfirmation = NULL WHERE EmailConfirmation = @Confirmation", false)) { cmd.AddIGuid("@Confirmation", confirmation); cmd.Execute(); } }
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 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 void Add() { using (SqlCmd cmd = new SqlCmd("INSERT INTO ContentPage VALUES (@Name, @Path, @Content) SET @Id = SCOPE_IDENTITY()", false)) { cmd.AddIString("@Name", 100, Name); cmd.AddIString("@Path", 100, Path); cmd.AddIString("@Content", -1, Content); cmd.AddOInt("@Id"); cmd.Execute(); Id = cmd.GetInt("@Id"); } }
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(string password, string ip, Guid emailConfirmation) { using (SqlCmd cmd = new SqlCmd("INSERT INTO [User] (UserName, UserEmail, UserPassword, TimeZone, IPAddress, IsActive, EmailConfirmation) VALUES (@UserName, @UserEmail, @Password, @TimeZone, @IPAddress, 0, @EmailConfirmation); SET @Id = SCOPE_IDENTITY();", false)) { cmd.AddIString("@UserName", 40, UserName); cmd.AddIString("@UserEmail", 50, Email); cmd.AddIString("@Password", 250, password); cmd.AddIString("@TimeZone", 50, TimeZone.Id); cmd.AddIString("@IPAddress", 100, ip); cmd.AddIGuid("@EmailConfirmation", emailConfirmation); cmd.AddOInt("@Id"); cmd.Execute(); Id = cmd.GetInt("@Id"); } }
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"); } }