Beispiel #1
0
 public async Task <PostPig.DataAccess.Florp.Task> Update(PostPig.DataAccess.Florp.Task task)
 {
     using (var connection = new NpgsqlConnection(connectionString))
     {
         return(task);
     }
 }
Beispiel #2
0
        public async Task <PostPig.DataAccess.Florp.Task> Create(PostPig.DataAccess.Florp.Task task)
        {
            using (var connection = new NpgsqlConnection(connectionString))
            {
                var command = new NpgsqlCommand(@"INSERT INTO public.task(id, name, description, created, user_id)
                VALUES (@id, @name, @description, @created, @userId)
                RETURNING id, name, description, created, user_id;", connection);

                command.Parameters.AddWithValue("id", task.Id);
                command.Parameters.AddWithValue("name", task.Name);
                command.Parameters.AddWithValue("description", task.Description);
                command.Parameters.AddWithValue("created", task.Created);
                command.Parameters.AddWithValue("userId", task.UserId);

                using (var reader = await command.ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        return(GetCurrent(reader));
                    }
                }

                return(null);
            }
        }
Beispiel #3
0
        public async Task <PostPig.DataAccess.Florp.Task> Create(PostPig.DataAccess.Florp.Task task)
        {
            using (var connection = new NpgsqlConnection(connectionString))
            {
                var command = new NpgsqlCommand(@"INSERT INTO public.task(id)
                VALUES(DEFAULT)
                RETURNING id;", connection);

                using (var reader = await command.ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        return(GetCurrent(reader));
                    }
                }

                return(null);
            }
        }