public IActionResult Add(int?id) { if (id.HasValue) { var item = _staticData.BuyableItems.FirstOrDefault(i => i.ItemNumber == id); var cartId = HttpContext.Session.GetString("CartId"); if (item != null && cartId != null) { var client = _httpClientFactory.CreateClient("staticdata"); var cmd = new AddItemToCart { Id = new Guid(cartId), Item = new OrderedItem { ItemNumber = item.ItemNumber, Artist = item.Artist, ReleasedYear = item.ReleasedYear, Title = item.Title, }, }; client.PostAsJsonAsync("api/VinylSaleWebShopService/AddItemToCart", cmd); } } return(RedirectToAction("Index")); }
public IEnumerable Handle(AddItemToCart c) { if (!open) { throw new CartNotOpen(); } yield return(new ItemAddedToCart { Id = c.Id, Item = c.Item, }); }
public void Add([FromBody] AddItemToCart command) { var cartId = _carts.GetCartIdForCurrentUser(); var price = _pricing.GetForProduct(command.Product); Apply(cartId, new ItemAddedToCart { Cart = cartId, Product = command.Product, Quantity = command.Quantity, NetItemPrice = price.Net, GrossItemPrice = price.Gross }); }
public IActionResult Put(string customerId, [FromBody] AddItemToCart cartItem) { if (cartItem == null) { return(BadRequest("invalid message")); } if (string.IsNullOrEmpty(customerId) || cartItem.UserId != customerId) { return(BadRequest("invalid customerId")); } var cart = _cartsystem.ActorSelection($"/user/cartcoordinator/cart-{customerId}"); cart.Tell(cartItem); return(Ok()); }
public void AddItemToCart(AddItemToCart cmd) { Startup.Dispatcher.SendCommand(cmd); }
public async Task <IActionResult> Post(AddItemToCart command) { await SendAsync(command.Bind(c => c.UserId, UserId)); return(NoContent()); }