public ActionResult Count(int id, string path)
        {
            int     count = 0;
            Website w     = websiteRepository.GetWebsiteByID(id);

            if (w != null)
            {
                Uri     u  = new Uri(path);
                Webpage wp = webpageRepository.GetWebpage(w.ID, u.AbsolutePath.Trim(), u.Query.Trim());
                if (wp != null)
                {
                    count = visitRepository.GetVisitsByWebpage(wp.ID).Count();
                }
            }
            return(Content(count.ToString()));
        }
        public ActionResult fr(int wid, Guid cc, string referer, string path, string wvri, string r, string b,
                               int sw, int sh, int st, int sl, string occ)
        {
            Visit     v  = null;
            VisitPage vp = null;
            Webpage   wp = null;

            //get the website
            Website w = websiteRepository.GetWebsiteByID(wid);

            if (w != null)
            {
                v = visitRepository.GetVisitByCC(cc);
                Uri u = new Uri(path);

                wp = webpageRepository.GetWebpage(w.ID, u.AbsolutePath.Trim(), u.Query.Trim());
                if (wp == null)
                {
                    wp = new Webpage()
                    {
                        DateCreated = DateTime.UtcNow,
                        Path        = u.AbsolutePath.Trim(),
                        QueryString = u.Query.Trim(),
                        Status      = RecordStatus.Active,
                        Website     = w
                    };
                    webpageRepository.InsertWebpage(wp);
                    webpageRepository.Save();
                }
                //if visit is not found than create a new visit
                if (v == null)
                {
                    int? oldVisitID = null;
                    Guid oldcc;
                    if (!string.IsNullOrEmpty(occ))
                    {
                        if (Guid.TryParse(occ, out oldcc))
                        {
                            Visit oldVisit = visitRepository.GetVisitByCC(oldcc);
                            if (oldVisit != null)
                            {
                                oldVisitID = oldVisit.ID;
                            }
                        }
                    }
                    v = new Visit()
                    {
                        CountryAbbr  = "",
                        DateCreated  = DateTime.UtcNow,
                        DateModified = null,
                        IPAddress    = Request.UserHostAddress,
                        LastPingDate = DateTime.UtcNow,
                        Referer      = referer,
                        Status       = RecordStatus.Active,
                        WebsiteVisitorReferenceID = wvri,
                        ClientCookie = cc,
                        Website      = w,
                        BrowserName  = b,
                        ScreenHeight = sh,
                        ScreenWidth  = sw,
                        LastVisitID  = oldVisitID
                    };
                    visitRepository.InsertVisit(v);
                    visitRepository.Save();
                }
                if (v != null)
                {
                    vp = visitRepository.GetLastVisitedPageofVisit(v.ID);
                }
                //if visitpage is not found or visitpage does not match with webpage in current context
                //than create a new visitpage obj
                if (vp == null || vp.webpage.ID != wp.ID)
                {
                    vp = new VisitPage()
                    {
                        LastPingDate  = DateTime.UtcNow,
                        visit         = v,
                        webpage       = wp,
                        DateCreated   = DateTime.UtcNow,
                        BrowserWidth  = null,
                        BrowserHeight = null,
                        ScrollLeft    = sl,
                        ScrollTop     = st
                    };
                    visitRepository.InsertVisitPage(vp);
                    visitRepository.Save();
                }
            }

            return(base.File(Server.MapPath("~/content/trans.png"), "image/png"));
        }