public int CreatNewElement(UserRoleModel element) { int rows; using (IDbConnection db = new SqlConnection(_configuration.GetConnectionString())) { var sqlQuery = "INSERT INTO [UriReduction].[UserRole](UserId,RoleId) VALUES(@UserId,@RoleId);"; rows = db.Execute(sqlQuery, element); } return(rows); }
public AssociatedUri GetElementById(int id) { List <AssociatedUri> uri; using (IDbConnection db = new SqlConnection(_connectionString.GetConnectionString())) { uri = db.Query <AssociatedUri>("SELECT * FROM [UriReduction].[AssociatedUri] where id = @id and DeletedAt is null", new { id }).ToList(); } return(CheckListOfUri(uri)); }
public async Task <IdentityResult> CreateAsync(AccountRole role, CancellationToken cancellationToken) { int rows; using (IDbConnection db = new SqlConnection(_configuration.GetConnectionString())) { var sqlQuery = "INSERT INTO [UriReduction].[Role](Name) VALUES(@Name);"; rows = await db.ExecuteAsync(sqlQuery, role); } if (rows > 0) { return(IdentityResult.Success); } return(IdentityResult.Failed()); }
public async Task <IdentityResult> CreateAsync(UserAccount user, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (user == null) { throw new ArgumentNullException(nameof(user)); } int rows; using (IDbConnection db = new SqlConnection(_connectionString.GetConnectionString())) { var sqlQuery = "INSERT INTO [UriReduction].[User](UserName, Password) VALUES(@UserName,@Password);"; rows = await db.ExecuteAsync(sqlQuery, user); } if (rows > 0) { return(IdentityResult.Success); } return(IdentityResult.Failed()); }