public void EditProductInShop(Guid shopProductGuid, double newPrice, int newQuantity) { var toEdit = ShopProducts.FirstOrDefault(p => p.Guid.Equals(shopProductGuid)); toEdit.Price = newPrice; toEdit.Quantity = newQuantity; }
public void RemoveProductFromShop(Guid shopProductGuid) { var toRemove = ShopProducts.FirstOrDefault(p => p.Guid.Equals(shopProductGuid)); //Need to remove from all users' cart in this shop first, to not break constraint ShopProducts.Remove(toRemove); }
public void VerifyShopProductExists(Guid shopProductGuid, ICloneableException <Exception> e) { var product = ShopProducts.FirstOrDefault(prod => prod.Guid.Equals(shopProductGuid)); if (product == null) { StackTrace stackTrace = new StackTrace(); var msg = string.Format(Resources.EntityNotFound, "product", shopProductGuid) + "In shop with Guid - {Guid}" + $" cant complete {stackTrace.GetFrame(1).GetMethod().Name}"; throw e.Clone(msg); } }
public async Task AddNewShopProductAsync(ShopProductParam param) { ShopProducts entity = new ShopProducts { ProductName = param.ProductName, PriceProduct = param.PriceProduct, ManufacturerProduct = param.ManufacturerProduct, DescriptionProduct = param.DescriptionProduct, IsAvaliable = param.IsAvaliable == "В наличии", TypeProdyctsEnum = EnumHelper.GetTypeProductsEnum(param.TypeProdycts), ShopId = 1 }; await _shopProductRepository.AddAsync(entity); }
// GET api/<controller>/5 public IHttpActionResult Get(int id) { ShopDTO shopDto = shopService.GetShop(id); if (shopDto == null) { return(NotFound()); } IEnumerable <ProductDTO> shopProductDtos = productService.GetShopProducts(id); ShopProducts shopProducts = new ShopProducts() { Shop = MappingUtil.MapInstance <ShopDTO, Shop>(shopDto), Products = MappingUtil.MapCollection <ProductDTO, Product>(shopProductDtos) }; return(Ok(shopProducts)); }
public void AddProductToShop(ShopProduct newShopProduct) { ShopProducts.Add(newShopProduct); }
private void ShopProductsToolStripMenuItem_Click(object sender, EventArgs e) { ShopProducts shopProducts = new ShopProducts(); shopProducts.ShowDialog(); }