This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Azure.Identity; | |
| using Azure.Messaging.ServiceBus; | |
| using Microsoft.Extensions.Azure; | |
| var builder = Host.CreateDefaultBuilder(args); | |
| builder.ConfigureAppConfiguration((ctx, config) => | |
| { | |
| var configBuilded = config.Build(); | |
| config.AddAzureAppConfiguration(options => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.Net.Http.Headers; | |
| using System.Globalization; | |
| using System.Security.Cryptography; | |
| using System.Text; | |
| const string ApiBaseUrl = "https://localhost/api"; | |
| const string ApiKey = "..."; | |
| const string RequestSigningKey = "..."; | |
| var httpClient = new HttpClient() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Threading.Tasks; | |
| using repository_dapper.Models; | |
| namespace repository_dapper.Repositories | |
| { | |
| public interface IUserRepository : IRepository<User> | |
| { | |
| Task<IEnumerable<User>> GetUsersAsync(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Data; | |
| namespace repository_dapper.Data | |
| { | |
| public class DbContext | |
| { | |
| private IDbStrategy _dbStrategy; | |
| public DbContext SetStrategy(string providerType) | |
| { | |
| _dbStrategy = providerType switch { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Data; | |
| using MySql.Data.MySqlClient; | |
| namespace repository_dapper.Data | |
| { | |
| public class MySqlStrategy : IDbStrategy | |
| { | |
| public IDbConnection GetConnection(string connectionString) | |
| { | |
| return new MySqlConnection(connectionString); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Data; | |
| namespace repository_dapper.Data | |
| { | |
| public interface IDbStrategy | |
| { | |
| IDbConnection GetConnection(string connectionString); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Data; | |
| using System.Linq; | |
| using System.Threading.Tasks; | |
| using Dapper.Contrib.Extensions; | |
| using repository_dapper.Data; | |
| using repository_dapper.Options; | |
| namespace repository_dapper.Repositories | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace repository_dapper.Options | |
| { | |
| public class DatabaseSettings | |
| { | |
| public string ProviderName { get; set; } | |
| public string ConnectionString { get; set; } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Linq; | |
| using System.Threading.Tasks; | |
| namespace repository_dapper.Repositories | |
| { | |
| public interface IRepository<TEntity> where TEntity : class | |
| { | |
| Task<IQueryable<TEntity>> FindAllAsync(); | |
| Task<TEntity> FindByIdAsync(Guid id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using Dapper.Contrib.Extensions; | |
| namespace repository_dapper.Features.User | |
| { | |
| [Table("Users")] | |
| public class UserDto | |
| { | |
| [ExplicitKey] | |
| public string Id { get; set; } |
NewerOlder