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
    Sep 05, 2019 @ 06:58
    Ove Lindholt Hansen
    0

    Save parameter

    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 354 posts 1638 karma points
    Sep 05, 2019 @ 16:18
    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