public async Task <IActionResult> AddToBasket([FromQuery] AddToBasketRequest addToBasketRequest) { var query = _mapper.Map <AddToBasketRequest, AddToBasketEvent>(addToBasketRequest); await _mediatr.Publish(query); return(Ok(true)); }
public AddToBasketResponse Invoke(AddToBasketRequest request) { var basket = GetBasket(); request.LineItem.Id = basket.LineItems.MaxOrDefault(li => li.Id) + 1; basket.LineItems.Add(request.LineItem); SaveBasket(basket); return new AddToBasketResponse(){LineItemCount = basket.LineItems.Count}; }
public async Task <OrderItem> AddToBasket(OrderingIndexSnapshot indexSnapShot, string userId) { var client = GetRequestClient <AddToBasketRequest>(); var request = new AddToBasketRequest { UserId = userId, IndexSnapshot = indexSnapShot }; var result = await client.GetResponse <AddToBasketResponse>(request); return(result.Message.OrderItem); }
public AddToBasketResponse Invoke(AddToBasketRequest request) { var basket = GetBasket(); request.LineItem.Id = basket.LineItems.MaxOrDefault(li => li.Id) + 1; basket.LineItems.Add(request.LineItem); SaveBasket(basket); return(new AddToBasketResponse() { LineItemCount = basket.LineItems.Count }); }
public async Task <IActionResult> Execute( [FromRoute] Guid restaurantId, [FromBody] AddToBasketRequest request) { var command = new AddToBasketCommand() { RestaurantId = restaurantId, MenuItemId = request.MenuItemId, Quantity = request.Quantity, }; var result = await sender.Send(command); return(result ? Ok() : Problem(result.Error)); }
public HttpResponseMessage Post(AddToBasketRequest request) { var basketService = this.sessionManager.GetItem <BasketService>(); var product = this.productLocatorService.FindProduct(request.ProductId, request.ProductTypeName); if (product == null) { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } basketService.AddToBasket(product, request.Quantity); this.sessionManager.PersistItem(basketService); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public IActionResult AddToBasket(AddToBasketRequest request) //productID { int basketCount = (HttpContext.Session.GetInt32("BasketCount") ?? 0) + 1; HttpContext.Session.SetInt32("BasketCount", basketCount); HttpContext.Session.TryGetValue("SessionId", out byte[] value); Guid?sessionId = null; if (value != null) { sessionId = new Guid(value); } var newSessionId = _cartService.AddToBasket(sessionId, request.ProductId); HttpContext.Session.Set("SessionId", newSessionId.ToByteArray()); return(RedirectToAction("Index", new { productId = request.ProductId })); }