Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ove Lindholt Hansen 1 post 71 karma points
    14 days ago
    Ove Lindholt Hansen
    0

    If I send a link to my website to someone, and they click the link, I want to record that they clicked the link. So my idea is: If I add a parameter to the link, like ?customer=100101 - how can I register the value 100101 in a file or database?

  • Shaishav Karnani from digitallymedia.com 273 posts 1198 karma points
    1 week ago
    Shaishav Karnani from digitallymedia.com
    0

    You can create your Custom Table and store the value.

    Code to create custom table https://our.umbraco.com/documentation/Extending/Database/

    Further how to write CRUD operation using scopeprovider is detailed below.

    Hope this helps.

    using Umbraco.Core.Scoping;
    
    namespace My.Website
        public class DatabaseExample
        {
            private IScopeProvider _scopeProvider;
    
            public DatabaseExample(IScopeProvider scopeProvider)
            {
                _scopeProvider = scopeProvider;
            }
    
            public void DoSomething()
            {
                using (var scope = _scopeProvider.CreateScope())
                {
                    // Scope.Database has what you need/want
                    scope.Database.Fetch<BlogComment>("Select * From tblBlogComment");
    
                    // You must always complete a scope
                    scope.Complete();
                }
            }
    
            public void DoInsert(BlogComment comment)
            {
                using (var scope = _scopeProvider.CreateScope())
                {
                    // Scope.Database has what you need/want
                    scope.Database.Insert(comment);
    
                    // You must always complete a scope
                    scope.Complete();
                }
            }
    
        }
    }
    

    Cheers,

    Shaishav

Please Sign in or register to post replies

Write your reply to:

Draft