예제 #1
0
        public ActionResult Redirect(int Id)
        {
            var model  = maps.Get(Id);
            var userId = User.Identity.GetUserId();

            if (model == null)
            {
                return(RedirectToAction("NotFound"));
            }

            var website = model.websitelink;

            if (_subscribed.GetSubscribedByUserId(userId).Count > 0)
            {
                _tracker.AddToTracker(model.Loansite, userId);
                var checkIfUserIsAvailable = _tracker.GetvaluebyproviderNameAndUserid(model.Loansite, userId);
                if (checkIfUserIsAvailable)
                {
                    var providertoupdate1 = _pd.GEtLoanProvidersbyName(model.Loansite);
                    providertoupdate1.CountVisit += 1;
                    if (_pd.Commit())
                    {
                        return(Redirect(website));
                    }
                }

                var providertoupdate = _pd.GEtLoanProvidersbyName(model.Loansite);
                providertoupdate.UniqueCountVisit += 1;
                providertoupdate.CountVisit       += 1;
                _pd.UpdateLoanProvides(providertoupdate);
                _pd.Commit();
                return(Redirect(website));
            }

            var returnUrl = Request.Url.ToString();

            BusinessLogic.UrlList.Add(returnUrl);
            var routeValues = new RouteValueDictionary
            {
                { "id", Id },
                { "returnUrl", returnUrl }
            };

            return(RedirectToAction("Subscribe", "Subscribed", routeValues
                                    ));
        }