public static Dto.Model.Order MapToDto(this Domain.Entities.Order order, List <Dto.Model.OrderProduct> items) { return(new Dto.Model.Order() { ID = order.ID, UpdatedTime = order.UpdatedTime, AddressID = order.AddressID, CreatedTime = order.CreatedTime, Status = order.Status, Items = items }); }
public ActionResult CheckOut(Order model) { var order = new Order(); if (TryUpdateModel(order)) { string cartId = ShoppingCart.GetCartId(HttpContext); ServiceLocator.FSharpBus.DispacthCommand(MessageBus.Command.NewSubmitOrderCommand(new Guid(cartId), order)); return RedirectToAction("Complete", "StoreEDAFSharp", new {id = order.Id}); } return View(); }
public void AddOrderDetails(Order order, Cart cart) { var cartItems = cart.lineCollection.ToList(); foreach (var item in cartItems) { var orderDetail = new OrderDetail { OrderId = order.OrderId, ProductId = item.Product.ProductId, Quantity = item.Quantity }; db.OrderDetails.Add(orderDetail); } db.SaveChanges(); }
public AddEditOrderPresenter(AddEditOrderView view, int orderId) { this.view = view; goods.AddRange(modelProxy.GoodsModel.GetAll().Where(x => x.IsActive == true)); if (orderId >= 0) { order = modelProxy.OrderModel.GetById(orderId); } else { order = new Domain.Entities.Order(); } }
private static List<Order> AddTenOrders() { List<Order> orderCollection = new List<Order>(); for (int i = 0; i < 9; i++) { Order order = new Order(); order.Customer = customerCollection[i]; order.comments.Add(new Comment() { Message = "commentfromOrder" + i, }); order.Operator = userCollection[i]; order.goodsList.Add(goodsRowCollection[i]); orderCollection.Add(order); } return orderCollection; }
public ActionResult CheckOut(Order model) { var order = new Order(); if (TryUpdateModel(order)) { order.OrderDate = DateTime.Now; storetUnitOfWork.Order.Add(order); storetUnitOfWork.Commit(); ShoppingCart cart = ShoppingCart.GetCart(HttpContext, storetUnitOfWork); cart.CreateOrder(order); return RedirectToAction("Complete", "Store", new {id = order.Id}); } return View(); }
public AddEditOrderPresenter(AddEditOrderView view, int orderId) { this.view = view; this.orderId = orderId; vm = new List<AddEditViewModel>(); if (orderId >= 0) { order = orderModel.GetById(orderId); foreach (GoodsRow row in order.GoodsList) { vm.Add(new AddEditViewModel() { Id = row.Id, Good = row.Goods, Count = row.Count, TotalCost = row.TotalPrice }); } } else { order = new Domain.Entities.Order(); } }
public Order ReceiveOrder(Cart cart, string username) { var order = new Order{ Username = username, OrderDate = DateTime.Now, Status = "Received", Total = cart.ComputeTotal(), //CompleteDate = new DateTime(1900,1,1) }; db.Orders.Add(order); AddOrderDetails(order, cart); db.SaveChanges(); cart.Clear(); return order; }
public Order CreateOrder(Domain.Entities.Order order, List <Application.Dto.Model.OrderProduct> orderProducts) { using (var connection = new NpgsqlConnection(_connectionString)) { connection.Open(); using (NpgsqlTransaction transaction = connection.BeginTransaction()) { try { var parameters = new { addressId = order.AddressID, createdTime = DateTime.UtcNow, status = order.Status }; order.ID = connection.ExecuteScalar <int>( sql: $"insert into retail.order (address_id, created_time, updated_time, status) values (@addressId, @createdTime, @updatedTime, @status) RETURNING id;", param: parameters, transaction: transaction); var products = orderProducts.Select(op => new { OrderID = order.ID, ProductID = op.ID, Quantity = op.Quantity }).ToArray(); connection.Execute( sql: $"insert into retail.orderproduct (order_id, product_id, quantity) values (@OrderID, @ProductID, @Quantity);", param: products, transaction: transaction); _productRepository.BulkUpdateProductQuantity(orderProducts); transaction.Commit(); } catch { transaction.Rollback(); throw; } } } return(order); }
public async Task <Unit> Handle(PurchaseProductCommand request, CancellationToken cancellationToken) { var entity = await _context.Products.FindAsync(request.ProductId); if (entity == null) { throw new NotFoundException("Product", request.ProductId); } if (entity.Count == 0 || entity.Count < request.Count) { throw new AvailabilityException("Product", request.ProductId); } entity.Count -= request.Count; var newOrder = new Domain.Entities.Order { OrderId = Guid.NewGuid(), UserId = request.UserId, ProductId = entity.ProductId, Date = DateTime.UtcNow, Count = request.Count, State = OrderState.CREATED }; _context.Orders.Add(newOrder); int value = await _context.SaveChangesAsync(cancellationToken); if (value > 0) { return(Unit.Value); } throw new Application.ExceptionHandler. ExceptionHandler(System.Net.HttpStatusCode.Conflict, new { message = "Buy product conflict" }); }
public void SaveAndNew() { Save(); order = new Domain.Entities.Order(); }
public OrderSubmittedEvent(Order order, Guid? id = null) { Order = order; Id = id ?? Guid.NewGuid(); }
public void CreateOrder(Order order) { decimal orderTotal = 0; List<Cart> cartItems = GetCartItems(); // Iterate over the items in the cart, adding the order details for each foreach (Cart item in cartItems) { var orderDetail = new OrderDetail { ProductId = item.ProductId, OrderId = order.Id, UnitPrice = item.Product.Price, Quantity = item.Count }; // Set the order total of the shopping cart orderTotal += (item.Count*item.Product.Price); _storetUnitOfWork.OrderDetails.Add(orderDetail); } // Set the order's total to the orderTotal count order.Total = orderTotal; _storetUnitOfWork.Commit(); EmptyCart(); }
public SubmitOrderCommand(string cartId, Order order) { _cartId = cartId; Order = order; Id = Guid.NewGuid(); }
public void SaveAndNew() { Save(); order = new Domain.Entities.Order(); NotifyPropertyChanged("SaveAndNew"); }
public bool ship(Order order) { throw new NotImplementedException(); }