Пример #1
0
        public User GetUserByUserName(string userName)
        {
            var query = @"
                select top 1
                    Id, Username, Email, PasswordHash 
                from 
                    Users
                where 
                    Username = @username";

            using (var conn = _dbConnectionProvider.GetOpenWsidnConnection())

            {
                var user = conn.Query <User>(query, new { userName });
                return(user.FirstOrDefault());
            }
        }
Пример #2
0
        public int CreateTask(CreateTask task)
        {
            using (var conn = _dbConnectionProvider.GetOpenWsidnConnection())
            {
                var sql = @"
                    insert into TasksToDo
                    ([Description], IntervalByHour, UserID)
                    values (@Description, @IntervalByHour, @UserId)
                    select SCOPE_IDENTITY()";

                var id = conn.ExecuteScalar <int>(sql, task);
                return(id);
            }
        }