示例#1
0
        public Client GetClientById(string id)
        {
            var sqlQuery = "SELECT * FROM Clients WHERE Id = @id";
            var client   = DBQueryExecuter <Client> .ExecuteQuery(connectionString, sqlQuery, new { id });

            return(client?.FirstOrDefault());;
        }
示例#2
0
        public Client AddClient(Client client)
        {
            var sqlQuery    = "INSERT INTO Clients (Id, SubNetwork) VALUES(@Id, @SubNetwork);SELECT * FROM Clients WHERE Id = @id";
            var addedClient = DBQueryExecuter <Client> .ExecuteQuery(connectionString,
                                                                     sqlQuery, new { client.Id, client.SubNetwork });

            return(addedClient?.FirstOrDefault());
        }
示例#3
0
        public string Delete(string clientId)
        {
            const string sqlQuery = "DELETE FROM Clients WHERE Id = @Id;" +
                                    "SELECT * FROM Clients WHERE Id = @id";
            var deletedClient = DBQueryExecuter <Client> .ExecuteQuery(connectionString,
                                                                       sqlQuery,
                                                                       new { Id = clientId });

            return(deletedClient?.FirstOrDefault() == null ? clientId : null);
        }
示例#4
0
        public Client Update(Client client)
        {
            const string sqlQuery = "UPDATE Clients SET Id = @Id, SubNetwork = @SubNetwork " +
                                    "WHERE Id = @Id; " +
                                    "SELECT * FROM Clients WHERE Id = @id";
            var updatedClient = DBQueryExecuter <Client> .ExecuteQuery(connectionString,
                                                                       sqlQuery,
                                                                       new { client.Id, client.SubNetwork });

            return(updatedClient?.FirstOrDefault());
        }
示例#5
0
        public List <Client> GetClients()
        {
            var clients = DBQueryExecuter <Client> .ExecuteQuery(connectionString, "SELECT * FROM Clients", new { });

            return(clients?.ToList());
        }