コード例 #1
0
        void set_imagefiles()
        {
            imagefiles  = new List <string>();
            product_ids = new List <int>();
            foreach (Product i in _context.Product)
            {
                if (i.P_Image == null)
                {
                    imagefiles.Add("no-image.jpg");
                }
                else
                {
                    imagefiles.Add(i.P_Image.ToString());
                }
                product_ids.Add(i.P_ID);
            }
            byte[] str   = HttpContext.Session.Get("Index");
            string index = Encoding.UTF8.GetString(str, 0, str.Length);

            current_image = imagefiles[int.Parse(index)];
            validReviews  = _context.GetReviewsOnProduct(product_ids[int.Parse(index)]);
        }
コード例 #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (HttpContext.Session.Get("Id") != null)
            {
                byte[] str = HttpContext.Session.Get("Id");
                string ID  = Encoding.UTF8.GetString(str, 0, str.Length);
                ViewData["Userid"] = ID;
            }
            if (HttpContext.Session.Get("Role") != null)
            {
                byte[] str  = HttpContext.Session.Get("Role");
                string Role = Encoding.UTF8.GetString(str, 0, str.Length);
                ViewData["UserRole"] = Role;
            }
            Product           = _context.getProduct(id.GetValueOrDefault());
            Products          = _context.getProductList();
            productSelectList = new SelectList(Products, "ID", "P_Name");
            SelectedId        = 1;

            validReviews = _context.GetReviewsOnProduct(id.GetValueOrDefault());

            return(Page());
        }