示例#1
0
        public PartialViewResult ViewsSummary()
        {
            RecentlyViewed views =
                (RecentlyViewed)(new RecentViewsModelBinder()).BindModel(this.ControllerContext, new ModelBindingContext());

            return(PartialView(views.GetRecentViews()));
        }
示例#2
0
        public void Init(RecentlyViewed in_pData, bool in_add, bool in_remove)
        {
            PlayerData playerData = new PlayerData();

            playerData.ProfileId  = in_pData.ProfileId;
            playerData.PlayerName = in_pData.Name;

            ItemData = playerData;
            base.Init(ItemData, in_add, in_remove);
        }
        public object BindModel(ControllerContext contrContext, ModelBindingContext modContext)
        {
            RecentlyViewed recView = (RecentlyViewed)contrContext.HttpContext.Session[key];

            if (recView == null)
            {
                recView = new RecentlyViewed();
                contrContext.HttpContext.Session[key] = recView;
            }
            return(recView);
        }
示例#4
0
        public ActionResult Selected(string handle)
        {
            ExtronWeb.Models.Product prod = new ExtronWeb.Models.Product();
            var model = prod.GetProduct(handle);

            if (model != null)
            {
                RecentlyViewed.Set(new { Name = model.Name, SubTitle = model.SubTitle, FileHandle = model.FileHandle, ViewDate = DateTime.Now }, Constants.LINKTYPE.PRODUCT);
                return(View(model));
            }
            return(Redirect("/Product"));
        }
示例#5
0
        public async Task Save(ClaimsPrincipal user, string link)
        {
            Validator.ArgumentNullException(user);

            var userId = this.userManager.GetUserId(user);

            var item = new RecentlyViewed
            {
                UserId      = userId,
                LinkUrl     = link,
                VisitedOn   = DateTime.UtcNow,
                DisplayLink = link.BuildDisplayLink(),
            };

            await this.repository.AddAsync(item);

            await this.repository.SaveChangesAsync();
        }
示例#6
0
        public async Task Save(ClaimsPrincipal user, string link)
        {
            Validator.ArgumentNullException(user);

            var userId = this.userManager.GetUserId(user);
            var list   = this.repository.All().ToList();
            var exists = list.FirstOrDefault(i => i.LinkUrl == link && i.UserId == userId);

            if (exists == null)
            {
                var item = new RecentlyViewed
                {
                    UserId      = userId,
                    LinkUrl     = link,
                    DisplayLink = StringExtensions.BuildDisplayLink(link),
                };
                await this.repository.AddAsync(item);
            }

            await this.repository.SaveChangesAsync();
        }
示例#7
0
        public ViewResult ShowDetailedDescription(int productId, string returnUrl)
        {
            if (returnUrl.Contains("/Products/AjaxList"))
            {
                returnUrl = "/Products/List";
            }

            ViewData["returnUrl"] = returnUrl;
            Product product = repository.Products.First(p => p.ProductID == productId);

            // create an instance of the recently viewed class  - to store the products viewed
            RecentlyViewed recentViews =
                (RecentlyViewed)(new RecentViewsModelBinder()).BindModel(this.ControllerContext, new ModelBindingContext());


            // make sure only one instance of each product is added to the view
            if (!recentViews.ContainsProduct(product))
            {
                recentViews.AddRecentProduct(product);
            }
            else
            {
                recentViews.AddProductAndMove(product);
            }

            IEnumerable <int> sizeIds  = product.ProductToSizes.Select(p => p.SizeId);
            IEnumerable <int> colorIds = product.ProductToColors.Select(p => p.ColorId);

            ProductInfo inf = new ProductInfo {
                SizeHolders = repository.
                              Sizes.Where(p => sizeIds.Contains(p.Id)).
                              Select(d => d.Value).ToArray(),
                Product      = product,
                ColorHolders = repository.
                               Colors.Where(p => colorIds.Contains(p.ColorId)).
                               Select(d => d.Value).ToArray()
            };

            return(View(inf));
        }
示例#8
0
 public PartialViewResult Clear(int?index)
 {
     RecentlyViewed.Clear(Constants.LINKTYPE.PRODUCT, index);
     return(PartialView("../Widgets/RecentlyViewed", RecentlyViewed.Get(Constants.LINKTYPE.PRODUCT)));
 }
示例#9
0
 public PartialViewResult Index()
 {
     return(PartialView("../Widgets/RecentlyViewed", RecentlyViewed.Get(Constants.LINKTYPE.PRODUCT)));
 }