コード例 #1
0
        public void DeletePriceComponent(int PriceComponentID)
        {
            ProductPriceComponents toBeDeleted = ctx.ProductPriceComponents.FirstOrDefault(x => x.PriceComponentID == PriceComponentID);

            if (toBeDeleted != null)
            {
                ctx.ProductPriceComponents.Remove(toBeDeleted);
                ctx.SaveChanges();
            }
        }
コード例 #2
0
        public IActionResult GoLive(AdminPendingProductsViewModel model)
        {
            InventoryItem item = _unitOfWork.InventoryItems.InventoryItems.FirstOrDefault(x => x.InventoryItemID == model.InventoryItemID);

            item.GoLive = true;
            ProductPriceComponents component = _unitOfWork.PriceComponents.PriceComponents
                                               .FirstOrDefault(x => x.InventoryItemID == item.InventoryItemID);

            component.SalePrice = model.SalePrice;

            _unitOfWork.InventoryItems.UpdateInventoryItem(item);
            _unitOfWork.PriceComponents.UpdatePriceComponent(component);

            return(RedirectToAction(nameof(PendingProducts)));
        }
コード例 #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)));
        }
コード例 #4
0
 public void UpdatePriceComponent(ProductPriceComponents priceComponent)
 {
     ctx.Update(priceComponent);
     ctx.SaveChanges();
 }
コード例 #5
0
 public void AddPriceComponent(ProductPriceComponents priceComponent)
 {
     ctx.ProductPriceComponents.Add(priceComponent);
     ctx.SaveChanges();
 }