Copied to clipboard

Flag this post as spam?

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


  • ibrahim TUNC 55 posts 133 karma points
    Feb 23, 2015 @ 10:27
    ibrahim TUNC
    0

    How many times viewed a video, a news etc... with Razor

    Hi !
    My name is ibrahim. I have a problem and I could not solve this problem. Can you help me?

    How do I show a video of how many times you watched? 

    Thanks.
    Best regards...

  • Steve Morgan 1349 posts 4459 karma points c-trib
    Feb 23, 2015 @ 16:30
    Steve Morgan
    0

    Hi,

     

    I would create an MVC API and create a custom table with nodeId, IP and the DateTime and store the events in here... you could update totals on the content nodes if you like but this might create a lot of publishes on a busy site. 

     

    There is a really good walk through on how to create an API on Umbraco.tv http://umbraco.tv/videos/developer/fundamentals/api-controllers/introduction/ or you could work through 

    http://www.nibble.be/?p=224

    https://our.umbraco.org/documentation/Reference/WebApi/

     

    Your Controller will look something like:

    namespace YourNameSpace.Controllers

    {

    public class VideosApiController : UmbracoApiController

    {

    // 

    // GET: /Umbraco/Api/VideosApi/..

     

    public VideosResults GetViews(int videoId)

    {

    Regardless of whether you use custom tables or not an API will let you get and update some values for these videos. In your API controller create set and get methods for Likes and Views and call the Sets via AJAX when the web visitors click them. 

     

    When you render the page via Razor get the the totals via your API get methods. 

     

     var VideosApi = new VideosApiController();
     VideosResults VideosResults = VideosApi.GetViews(videoId);

     

     HTH

     

     Steve

Please Sign in or register to post replies

Write your reply to:

Draft