public async Task <IActionResult> Get(string userId) { var exception = new Exception(); try { IUserActors actor = GetActor(userId); Dictionary <Guid, int> products = await actor.GetCart(); return(Ok(new CartDetails() { UserId = userId, Items = products.Select( p => new CartItem { ProductId = p.Key.ToString(), Quantity = p.Value }).ToArray() })); } catch (Exception ex) { exception = ex; } return(BadRequest(exception)); }
public async Task <IActionResult> Add(string userId, [FromBody] AddCartItem request) { var exception = new Exception(); try { IUserActors actor = GetActor(userId); await actor.AddToCart(request.ProductId, request.Quantity); return(Accepted()); } catch (Exception ex) { exception = ex; } return(BadRequest(exception)); }