Exemple #1
0
        public async Task <ActionResult> ViewShopProduct(long id)
        {
            ShopProductViewModel model   = new ShopProductViewModel();
            ProductViewModel     product = await productService.getProduct(id);

            if (product == null)
            {
                HttpResponseModel resp = new HttpResponseModel();
                resp.ReasonMessage = "Product ID not present in database.";
                return(View("Failure", resp));
            }
            model.Id              = product.Id;
            model.Title           = product.Title;
            model.Description     = product.Description;
            model.DescriptionFull = product.DescriptionFull;
            model.Views           = product.Views;
            model.IsActive        = product.IsActive;
            model.CreatedAt       = product.CreatedAt;
            model.UpdatedAt       = product.UpdatedAt;
            model.ShopId          = product.ShopId;
            model.Stock           = product.Stock;
            model.Price           = product.Price;
            model.Image           = product.Image;
            model.Category        = product.Category;
            model.CategoryName    = product.CategoryName;
            model.Configuration   = await service.GetShopConfig(product.ShopId);

            ViewBag.ProductsInCart = Session["cart"] != null ? ((List <CartProduct>)Session["cart"]).Count : 0;
            return(View(model));
        }
Exemple #2
0
        public IActionResult SearchProduct(int?id, string search, int?sortBy)
        {
            ShopProductViewModel vm = new ShopProductViewModel()
            {
                Products   = _productService.SearchProduct(id, search, sortBy),
                Categories = _categoryService.GetCatagories()
            };

            return(PartialView("ProductPartial", vm));
        }
        public IActionResult Index()
        {
            ShopProductViewModel vm = new ShopProductViewModel()
            {
                Products = _productService.GetAllProducts(),
                Blogs    = _blogService.GetAllProducts()
            };

            return(View(vm));
        }
Exemple #4
0
        public ActionResult Product(int id)
        {
            ShopProductViewModel model = new ShopProductViewModel();

            model.series = SeriesService.GetSeries(id).FirstOrDefault();
            if (model.series != null)
            {
                model.series.Products = ProductService.GetProducts(SeriesID: id).ToArray();
            }

            return(View(model));
        }
Exemple #5
0
        public void ImageUrlShouldBeEqual()
        {
            var model = new ShopProductViewModel
            {
                Id       = 4,
                Price    = 10,
                Discount = 10,
                Name     = "Boza",
            };

            Assert.Equal($"/images/product_4.jpg", model.ImageUrl);
        }
Exemple #6
0
        public void SalePriceShouldBeEqual()
        {
            var model = new ShopProductViewModel
            {
                Id       = 10,
                Price    = 10,
                Discount = 10,
                Name     = "Boza",
            };

            Assert.Equal(9.00m, model.SalePrice);
        }
Exemple #7
0
        public void SalePriceShouldBeNotEqual(decimal price, decimal discount)
        {
            var model = new ShopProductViewModel
            {
                Id       = 3,
                Price    = price,
                Discount = discount,
                Name     = "Boza",
            };

            Assert.NotEqual(4m, model.SalePrice);
        }