コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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());
        }