public async Task CreateOrder([FromRoute] string userName, [FromBody] OrderProductDto dto) { HttpClient client = _httpClientFactory.CreateClient(); client.BaseAddress = new Uri("https://localhost:5001/"); var requestDto = new CreateOrderDto { Count = dto.Count, Item = dto.Item }; HttpResponseMessage response = await client.PostAsJsonAsync("api/OrderManager", requestDto); if (!response.IsSuccessStatusCode) { throw new Exception("Order failed"); } int orderId = Convert.ToInt32(await response.Content.ReadAsStringAsync()); List <int> orderList; if (!_userManager.TryGetValue(userName, out orderList)) { orderList = new List <int>(); _userManager[userName] = orderList; } orderList.Add(orderId); }
/// <summary>Adds the order product.</summary> /// <param name="orderProductDto">The order product dto.</param> /// <returns></returns> public async Task <OrderProductDto> AddOrderProduct(OrderProductDto orderProductDto) { OrderProduct orderProduct = _mapper.Map <OrderProductDto, OrderProduct>(orderProductDto); await _dataContext.OrderProducts.AddAsync(orderProduct); // return orderProductDto; return(null); }
public OrderProductDto DeleteProductForOrder(int orderProductId) { PedidoProducto pedidoProducto = _galaxyTallerContext.PedidoProducto.Where(w => w.PedidoProductoId == orderProductId).FirstOrDefault(); OrderProductDto orderProductDto = GetProductForOrder(orderProductId); _galaxyTallerContext.PedidoProducto.Remove(pedidoProducto); _galaxyTallerContext.SaveChanges(); return(orderProductDto); }
public async Task CreateOrder([FromRoute] string userName, [FromBody] OrderProductDto dto) { int orderId = await _client.CreateOrder(dto.Item, dto.Count); if (!_userManager.TryGetValue(userName, out List <int> orderList)) { orderList = new List <int>(); _userManager[userName] = orderList; } orderList.Add(orderId); }
/// <summary>Deletes the order.</summary> /// <param name="id">The identifier.</param> /// <returns></returns> public async Task <bool> DeleteOrder(int id) { OrderProductDto orderProduct = await _unitOfWork.OrderProductRepository.GetOrderProduct(id); if (orderProduct == null) { return(false); } _unitOfWork.OrderProductRepository.Delete(orderProduct); return(await _unitOfWork.OrderProductRepository.SaveAll()); }
private async Task <IEnumerable <OrderProductDto> > GetProductInformation(IEnumerable <ShoppingCartItemDto> shoppingCartItems) { // Get catalog information for shoppingcart items var orderedProducts = new List <OrderProductDto>(); foreach (var item in shoppingCartItems) { var orderedProduct = new OrderProductDto(); orderedProduct.Product = await GetCatalogItemById(item.CatalogItemId); orderedProduct.Amount = item.Amount; orderedProducts.Add(orderedProduct); } return(orderedProducts); }
public async Task OnGetAsync(long?id) { if (id.HasValue) { Dto = await _service.GetByIdAsync(id.Value); if (Dto == null) { throw new KuDataNotFoundException(); } ViewData["Mode"] = "Edit"; } else { Dto = new OrderProductDto(); ViewData["Mode"] = "Add"; } }
public DataWrapper <int> OrderProductAdd(OrderProductDto orderProductDto) { var result = new DataWrapper <int>(); try { string sqlExpression = "Order_Product_Add"; result.Data = _connection.Query <int>(sqlExpression, new { orderProductDto.OrderId, orderProductDto.ProductId, orderProductDto.Quantity }, commandType: CommandType.StoredProcedure).FirstOrDefault(); result.IsOk = true; } catch (Exception e) { result.ExceptionMessage = e.Message; } return(result); }
public DataWrapper <OrderDto> CreateFullOrder(OrderDto orderDto) { var orderProduct = new OrderProductDto(); var result = new DataWrapper <OrderDto>(); try { orderDto.Id = OrderAdd(orderDto).Data; foreach (var product in orderDto.ProductDto) { orderProduct.OrderId = orderDto.Id.Value; orderProduct.ProductId = product.Id; orderProduct.Quantity = orderDto.Quantity; OrderProductAdd(orderProduct); } result.Data = OrderGetById(orderDto.Id.Value).Data; result.IsOk = true; } catch (Exception e) { result.ExceptionMessage = e.Message; } return(result); }
public ActionResult <OrderProductDto> DeleteProductForOrder(int orderProductId) { OrderProductDto orderProductDto = _orderApplicationService.DeleteProductForOrder(orderProductId); return(Ok(orderProductDto)); }
public ActionResult <OrderProductDto> UpdateProductForOrder(int orderProductId, [FromBody] OrderProductUpdateDto orderProductUpdateDto) { OrderProductDto orderProduct = _orderApplicationService.UpdateProductForOrder(orderProductId, orderProductUpdateDto); return(Ok(orderProduct)); }
public ActionResult <OrderProductDto> CreateProductForOrder(int orderId, [FromBody] OrderProductCreateDto orderProductCreate) { OrderProductDto orderProduct = _orderApplicationService.CreateProductForOrder(orderId, orderProductCreate); return(Ok(orderProduct)); }
public ActionResult <OrderProductDto> GetProductForOrder(int orderProductId) { OrderProductDto orderProduct = _orderApplicationService.GetProductForOrder(orderProductId); return(Ok(orderProduct)); }
public OrderProduct(OrderProductDto orderProduct) { Title = orderProduct.Product.Title; Price = orderProduct.Product.Price; Amount = orderProduct.Amount; }
public OrderProductDto GetProductForOrder(int orderProductId) { OrderProductDto result = QueryGetOrderProduct(0, orderProductId).FirstOrDefault(); return(result); }