Ejemplo n.º 1
0
        public ActionResult Products()
        {
            var seller = GetSeller();
            var res    = new SellerProductsViewModel
            {
                Products = seller.Products.Where(item => !item.IsDeleted && item.Amount > 0).Select(item => _mapper.Map <ProductViewModel>(item)).ToList(),
                Helper   = _mapper.Map <SellerProfileHelperViewModel>(seller)
            };

            return(View(res));
        }
Ejemplo n.º 2
0
        public ActionResult ProductsArchive()
        {
            var seller = GetSeller();
            var res    = new SellerProductsViewModel
            {
                Products = seller.Products.Where(item => item.IsDeleted || item.Amount == 0).Select(item => _mapper.Map <ProductViewModel>(item)).ToList(),
                Helper   = _mapper.Map <SellerProfileHelperViewModel>(seller)
            };

            ViewBag.IsArchive = true;
            return(View("Products", res));
        }
Ejemplo n.º 3
0
        public IActionResult OfferNewProduct(SellerProductsViewModel model)
        {
            InventoryItem item = new InventoryItem
            {
                Seller        = _userManager.Users.FirstOrDefault(x => x.UserName == User.Identity.Name),
                Product       = _unitOfWork.Products.Products.FirstOrDefault(x => x.Name == model.ProductName),
                StockQuantity = model.InventoryItem.StockQuantity,
                GoLive        = false
            };

            ProductPriceComponents components = new ProductPriceComponents
            {
                InventoryItem = item,
                FromDate      = DateTime.Today,
                BasePrice     = model.BasePrice
            };

            _unitOfWork.InventoryItems.AddInventoryItem(item.Seller, item);
            _unitOfWork.PriceComponents.AddPriceComponent(components);
            return(RedirectToAction(nameof(ProductsOffered)));
        }