public void DeletePriceComponent(int PriceComponentID) { ProductPriceComponents toBeDeleted = ctx.ProductPriceComponents.FirstOrDefault(x => x.PriceComponentID == PriceComponentID); if (toBeDeleted != null) { ctx.ProductPriceComponents.Remove(toBeDeleted); ctx.SaveChanges(); } }
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))); }
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))); }
public void UpdatePriceComponent(ProductPriceComponents priceComponent) { ctx.Update(priceComponent); ctx.SaveChanges(); }
public void AddPriceComponent(ProductPriceComponents priceComponent) { ctx.ProductPriceComponents.Add(priceComponent); ctx.SaveChanges(); }