static void Main(string[] args) { SQLUserRepository sqlUserRepository = new SQLUserRepository(); User Alex = new User { Age = 19, Name = "Alex" }; User AlexUpd = new User { Id = 2, Age = 22, Name = "AlexUpd" }; User UserForRemove = new User { Age = 17, Name = "UserForRemove" }; //sqlUserRepository.Add(Alex); //sqlUserRepository.Update(AlexUpd); //sqlUserRepository.Remove(1); // GetAll ------------------------------------------------------ Console.WriteLine("\nТестирование метода GetAll:"); List <User> users = sqlUserRepository.GetAll().ToList(); foreach (User user in users) { Console.WriteLine(user.ToString()); } // Get ---------------------------------------------------------- Console.WriteLine("\nТестирование метода Get:"); User TestGet = sqlUserRepository.Get(-1); if (TestGet == null) { Console.WriteLine("Пользователь не найден"); } else { Console.WriteLine(TestGet.ToString()); } // AddUserUsingProcedure ----------------------------------------- Console.WriteLine($"\nТестирование метода AddUserUsingProcedure:"); int id = sqlUserRepository.AddUserUsingProcedure("UserTestProc", 23); Console.WriteLine($"Id добавленного объекта: {id}"); // Транзакзия ---------------------------------------------------- Console.WriteLine($"\nТестирование транзакции:"); TestTransaction(); Console.Read(); }
private void InitializeRepoDict() { IUserRepository userRepo = new SQLUserRepository(this); IUsersBoardsRepository usersBoardsRepo = new SQLUsersBoardsRepository(this); IBoardRepository boardRepo = new SQLBoardRepository(this, usersBoardsRepo, userRepo); IColumnRepository columnRepo = new SQLColumnRepository(this, boardRepo); ITaskRepository taskRepo = new SQLTaskRepository(this, columnRepo); _repositories = new Dictionary <string, Object>() { { "SQLBoardRepository", boardRepo }, { "SQLUsersBoardsRepository", usersBoardsRepo }, { "SQLUserRepository", userRepo }, { "SQLTaskRepository", taskRepo } }; }
public UserService() { string connectionString = "Data Source=.;Initial Catalog=FireChat;Integrated Security=True"; repository = new SQLUserRepository(connectionString); }
public ApiController(ILogger <ApiController> logger, UserContext context) { _logger = logger; _sqlUserHandler = new SQLUserRepository(context); }