コード例 #1
0
        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();
        }
コード例 #2
0
        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 }
            };
        }
コード例 #3
0
        public UserService()
        {
            string connectionString = "Data Source=.;Initial Catalog=FireChat;Integrated Security=True";

            repository = new SQLUserRepository(connectionString);
        }
コード例 #4
0
 public ApiController(ILogger <ApiController> logger, UserContext context)
 {
     _logger         = logger;
     _sqlUserHandler = new SQLUserRepository(context);
 }