/// <summary> /// 显示分页 /// </summary> /// <param name="pageindex"></param> private void ShowGrid(int pageindex) { DataTable dt = _DataTablePage.GetPagedTable(this._DataTable, pageindex, pagesize); int count = dt.Rows.Count; for (int i = 0; i < count; i++) { string sysno = dt.Rows[i][1].ToString(); OrderItemEntity item = this._Hashtable[sysno] as OrderItemEntity; if (item != null) { LoadData(item); break; } } if (count > 0) { this.lbPage.Text = string.Format("第{0}页/共{1}页", pageindex, pagecount); this.lbPage.Visible = true; } else { this.lbPage.Visible = false; } this.ShowNextGrid(pageindex); this.FocusCellNo(); }
protected static object ConvertToExpectedBody( OrderItemEntity orderItemEntity, IDictionary <string, ServiceRecipientEntity> serviceRecipients, IList <OrderItemRecipientEntity> orderItemRecipients, IDictionary <string, PricingUnitEntity> pricingUnits) { return(new { orderItemEntity.CatalogueItemId, orderItemEntity.CurrencyCode, EstimationPeriod = orderItemEntity.EstimationPeriod?.ToString(), ItemUnit = new { Name = orderItemEntity.PricingUnitName, pricingUnits[orderItemEntity.PricingUnitName].Description, }, orderItemEntity.PriceId, orderItemEntity.Price, orderItemEntity.ProvisioningType, ServiceRecipients = orderItemRecipients.Select(r => new { r.DeliveryDate, serviceRecipients[r.OdsCode].Name, r.OdsCode, r.Quantity, }).ToArray(), TimeUnit = orderItemEntity.TimeUnit is null ? null : new { Name = orderItemEntity.TimeUnit.ToString()?.ToLowerInvariant(), Description = orderItemEntity.TimeUnit?.ToDescription(), }, Type = orderItemEntity.CataloguePriceType, });
private void LoadData(OrderItemEntity item) { this._OrderItemEntity = null; if (item == null) { base.ShowMessage("无拣货信息!", false, EnMessageType.G, false); return; } this.lbProduct2.Text = item.outerid; //商家编码 this.lbBarCode2.Text = item.cbarcode; //商品条码 this.lbCellNo2.Text = item.fromitemcode; //拣货库位 this.lbQty2.Text = item.amount; //待拣货数量 if (item.amount == "1") { this.txtCount.Text = "1"; } else { this.txtCount.Text = string.Empty; } this._OrderItemEntity = item; }
public static OrderItemModel ToModel(this OrderItemEntity item) => new OrderItemModel { Id = item.Id, Description = item.Description, Name = item.Name, Quantity = item.Quantity };
public async Task <OrderItem> CreateOrderItemAsync(Guid orderId, Guid productId, int quantity, CancellationToken cancellationToken = default) { using (ShoppingCartDbContext context = _dbContextFactory()) { OrderEntity order = context.Orders.SingleOrDefault(a => a.Id == orderId); if (order == null) { throw new OrderNotFoundException($"Order with ID {orderId} not found"); } ProductEntity product = context.Products.SingleOrDefault(a => a.Id == productId); if (product == null) { throw new ProductNotFoundException($"Product with ID {productId} not found"); } OrderItemEntity orderItem = new OrderItemEntity { Id = Guid.NewGuid(), Order = order, Product = product, Quantity = quantity, }; context.OrderItems.Add(orderItem); await context.SaveChangesAsync(cancellationToken); return(BuildOrderItemFromEntity(orderItem)); } }
/// <summary> /// 生成订单的服务方法 /// </summary> /// <param name="orderId">订单号</param> /// <param name="userId">用户号</param> /// <param name="buyItems">购买的商品简要清单</param> /// <returns>订单是否创建成功</returns> public bool CreateOrder(int orderId, int userId, IEnumerable <BuyProductDto> buyItems) { //在分布式事务的发起端,需要先定义分布式事务标识: string DT_Identity = System.Guid.NewGuid().ToString(); //使用3阶段提交的分布式事务,保存订单到数据库 OrderDbContext context = new OrderDbContext(); DTController controller = new DTController(DT_Identity); return(controller.DistTrans3PCRequest <bool>(DTS_Proxy, context.CurrentDataBase, db => { //先请求商品服务,扣减库存,并获取商品的仓库信息 ServiceRequest request = new ServiceRequest(); request.ServiceName = "ProductService"; request.MethodName = "UpdateProductOnhand"; request.Parameters = new object[] { DT_Identity, buyItems }; List <SellProductDto> sellProducts = productProxy.RequestServiceAsync <List <SellProductDto> >(request).Result; #region 构造订单明细和订单对象 // List <OrderItemEntity> orderItems = new List <OrderItemEntity>(); OrderEntity order = new OrderEntity() { ID = orderId, OwnerID = userId, OrderTime = DateTime.Now, OrderName = "Prudoct:" }; foreach (BuyProductDto item in buyItems) { //注意:在商品数据库上,前面更新商品,但还没有提交事务,下面这个查询直接使用的话会导致查询等待,因为SQLSERVER的事务隔离级别是这样的 //所以 GetProductInfo 的实现需要注意。 ProductDto product = this.GetProductInfo(item.ProductId).Result; OrderItemEntity temp = new OrderItemEntity() { OrderID = orderId, ProductID = product.ID, BuyNumber = item.BuyNumber, OnePrice = product.Price, ProductName = product.ProductName }; temp.StoreHouse = (from i in sellProducts where i.ProductId == temp.ProductID select i.StoreHouse).FirstOrDefault(); orderItems.Add(temp); order.OrderName += "," + temp.ProductName; order.AmountPrice += temp.OnePrice * temp.BuyNumber; } // #endregion //保存订单数据到数据库 context.Add <OrderEntity>(order); context.AddList <OrderItemEntity>(orderItems); return true; })); }
private void AddOrderItem(OrderEntity orderEntity, List <ProductEntity> products, OrderItemWithState orderItemWithState) { var productEntity = products.SingleOrDefault(product => product.Id == orderItemWithState.OrderItem.ProductId); if (productEntity == null) { throw new ProductNotFoundException("Specified product is not found."); } var orderItemEntity = new OrderItemEntity { OrderId = orderEntity.Id, Quantity = orderItemWithState.OrderItem.Quantity, /* Product information needs to be recorded, in case * if master product data is changed then you'll lose the orginal information that has been viewed * at the time of order creation */ ProductId = productEntity.Id, ProductName = productEntity.Name, Height = productEntity.Height, Weight = productEntity.Weight, Barcode = productEntity.Name, Image = productEntity.Name, SKU = productEntity.SKU, }; _dbContext.OrderItems.Add(orderItemEntity); }
public async Task ThenTheCatalogueSolutionOrderItemIsUpdated() { var orderItem = await OrderItemEntity.FetchByOrderItemId(_settings.ConnectionString, _updateCatalogueSolutionOrderItemRequest.OrderItemId); _updateCatalogueSolutionOrderItemRequest.AssertPayload(orderItem); }
public void SubmitOrderRequest(OrderRequest request) { using (var db = new OrderDataContext()) { var order = new OrderEntity { ConfirmationEmailAddress = request.ConfirmationEmailAddress, DateCreated = DateTime.Now, RequestedDeliveryDate = request.RequestedDeliveryDate, VendorNumber = request.VendorNumber, OrderItems = new Collection <OrderItemEntity>() }; foreach (var item in request.LineItems) { var orderItem = new OrderItemEntity { ProductIdentifier = item.ProductIdentifier, Quantity = item.Quanity }; order.OrderItems.Add(orderItem); } db.Orders.Add(order); db.SaveChanges(); } }
public void AssertPayload(OrderItemEntity actual) { var expected = OrderItemEntityBuilder .Create() .WithOrderId(OrderId) .WithOdsCode(Payload.OdsCode) .WithCatalogueItemId(Payload.CatalogueSolutionId) .WithCatalogueItemType(CatalogueItemType.Solution) .WithCatalogueItemName(Payload.CatalogueSolutionName) .WithDeliveryDate(Payload.DeliveryDate) .WithQuantity(Payload.Quantity.GetValueOrDefault()) .WithEstimationPeriod(Payload.EstimationPeriod) .WithProvisioningType(Payload.ProvisioningType.GetValueOrDefault()) .WithCataloguePriceType(Payload.CataloguePriceType.GetValueOrDefault()) .WithCurrencyCode(Payload.CurrencyCode) .WithPricingUnitTierName(Payload.ItemUnitName) .WithPricingUnitDescription(Payload.ItemUnitNameDescription) .WithPrice(Payload.Price) .Build(); actual.Should().BeEquivalentTo(expected, config => config .Excluding(entity => entity.OrderItemId) .Excluding(entity => entity.Created) .Excluding(entity => entity.LastUpdated)); }
public static OrderItemEntityBuilder Create(OrderItemEntity orderItemEntity) { if (orderItemEntity is null) { throw new ArgumentNullException(nameof(orderItemEntity)); } return(new OrderItemEntityBuilder( orderItemEntity.OrderId, orderItemEntity.OdsCode, orderItemEntity.CatalogueItemId, orderItemEntity.CatalogueItemType, orderItemEntity.CatalogueItemName, orderItemEntity.DeliveryDate, orderItemEntity.Quantity, orderItemEntity.EstimationPeriod, orderItemEntity.ProvisioningType, orderItemEntity.CataloguePriceType, orderItemEntity.CurrencyCode, orderItemEntity.TimeUnit, orderItemEntity.PricingUnitTierName, orderItemEntity.PricingUnitDescription, orderItemEntity.Price, orderItemEntity.Created, orderItemEntity.LastUpdated)); }
public OrderItem2DTO(OrderItemEntity cartItemEntity) { Id = cartItemEntity.Id; Quantity = cartItemEntity.Quantity; Actived = cartItemEntity.Actived; Deleted = cartItemEntity.Deleted; Product = cartItemEntity.Product; }
/// <summary> setups the sync logic for member _orderItem</summary> /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param> private void SetupSyncOrderItem(IEntity2 relatedEntity) { if (_orderItem != relatedEntity) { DesetupSyncOrderItem(true, true); _orderItem = (OrderItemEntity)relatedEntity; base.PerformSetupSyncRelatedEntity(_orderItem, new PropertyChangedEventHandler(OnOrderItemPropertyChanged), "OrderItem", EventTestOrderItemEntity.Relations.OrderItemEntityUsingOrderItemId, true, new string[] { }); } }
public void Mapper_IncludesOrderItemBaseProperties() { var mockEntity = new OrderItemEntity { UpdatedAt = new DateTime(2011, 12, 10, 3, 2, 1) }; var mockDto = GetMapper().Map <OrderItem>(mockEntity); Assert.Equal(mockEntity.UpdatedAt, mockDto.UpdatedAt); }
/// <summary> Initializes the class members</summary> protected virtual void InitClassMembers() { _eventTest = null; _orderItem = null; PerformDependencyInjection(); // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers // __LLBLGENPRO_USER_CODE_REGION_END OnInitClassMembersComplete(); }
public static OrderItemModel ToModel(this OrderItemEntity entity) { var model = new OrderItemModel() { Name = entity.Book.Name, PublishDate = entity.Book.PublishYear, Quantity = entity.Quantity }; return(model); }
public static OrderItemEntity ToEntity(this OrderItemModel model, int orderId) { var entity = new OrderItemEntity() { BookId = model.Id, OrderId = orderId, Quantity = model.Quantity }; return(entity); }
public void SubmitForm(OrderItemEntity entity, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); service.Update(entity); } else { entity.Create(); service.Insert(entity); } }
public void Mapper_IncludesOrderItem() { var entity = new OrderItemEntity { Id = 12, Name = "Doge" }; var apiModel = GetMapper().Map <OrderItem>(entity); Assert.Equal(entity.Id, apiModel.Id); Assert.Equal(entity.Name, apiModel.Name); }
public void AssertPayload(OrderItemEntity actual) { var expected = new { OrderId, OrderItemId, DeliveryDate = Payload.DeliveryDate?.Date, Payload.EstimationPeriod, Payload.Price }; actual.Should().BeEquivalentTo(expected); }
internal async Task ThenTheOrderItemEstimationPeriodIsSetTo(string estimationPeriodName) { TimeUnit?expectedEstimationPeriod = null; if (!string.IsNullOrWhiteSpace(estimationPeriodName)) { expectedEstimationPeriod = Enum.Parse <TimeUnit>(estimationPeriodName, true); } var orderItem = await OrderItemEntity.FetchByKey(settings.ConnectionString, OrderId, catalogueItemId); orderItem.EstimationPeriod.Should().Be(expectedEstimationPeriod); }
public async Task <OrderEntity> CreateOrderAsync(string buyerEmail, int deliveryMethodId, string basketId, AddressAggregate shippingAddress) { // get basket from the repo var basket = await _basketRepo.GetBasketAsync(basketId); // get items from product repo var items = new List <OrderItemEntity>(); foreach (var item in basket.Items) { var productItem = await _unitOfWork.Repository <ProductEntity>().GetByIdAsync(item.Id); var itemOrdered = new ProductItemOrdered(productItem.Name, productItem.Id, productItem.PictureUrl); var orderItem = new OrderItemEntity(itemOrdered, productItem.Price, item.Quantity); items.Add(orderItem); } // get delivery method from the repo var deliveryMethod = await _unitOfWork.Repository <DeliveryMethodEntity>().GetByIdAsync(deliveryMethodId); // calculate subtotal var subTotal = items.Sum(a => a.Price * a.Quantity); // check to see if order is exists var spec = new OrderByPaymentIntentIdSpecification(basket.PaymentIntentId); var existingOrder = await _unitOfWork.Repository <OrderEntity>().GetEntityWithSpec(spec); if (existingOrder != null) { _unitOfWork.Repository <OrderEntity>().Delete(existingOrder); await _paymentService.CreateOrUpdatePaymentIntent(basket.PaymentIntentId); } // create order var order = new OrderEntity(items, buyerEmail, deliveryMethod, shippingAddress, subTotal, basket.PaymentIntentId); _unitOfWork.Repository <OrderEntity>().Add(order); // save to db var result = await _unitOfWork.Complete(); // return order if (result <= 0) { return(null); } return(order); }
public long SaveCancellationFeeOrderItem() { using (var myAdapter = PersistenceLayer.GetDataAccessAdapter()) { var orderItemEntity = new OrderItemEntity { Type = (short)OrderItemType.CancellationFee }; if (!myAdapter.SaveEntity(orderItemEntity)) { throw new PersistenceFailureException(); } return(orderItemEntity.OrderItemId); } }
public void SaveOrderItems(long orderId, IList <OrderItemEntity> orderItemsToSave) { if (orderItemsToSave == null || !orderItemsToSave.Any()) { return; } var sqlParams = new [] { OrderItemEntity.BindOrderItemTable("@@orderItems", orderItemsToSave), new SqlParameter("@orderId", SqlDbType.BigInt) { Value = orderId } }; dbContext.ExecuteNonQuery("SaveOrderItems", Timeout, sqlParams); }
public static OrderItemModel CreateFromEntity(OrderItemEntity o) { if (o == null) { return(null); } return(new OrderItemModel { OrderId = o.OrderId, DishId = o.DishId, Quantity = o.Quantity, ItemStatus = o.ItemStatus, }); }
public static OrderItemModel CreateFromEntity(OrderItemEntity o) { if (o == null) { return null; } return new OrderItemModel { OrderId = o.OrderId, DishId = o.DishId, Quantity = o.Quantity, ItemStatus = o.ItemStatus, }; }
/// <summary> /// 获取实体(异步方式) /// </summary> /// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param> /// <param name="dict">参数的名/值集合</param> /// <returns></returns> public virtual async Task <OrderItemEntity> GetEntityAsync(string strWhere, Dictionary <string, object> dict = null) { OrderItemEntity obj = null; string strSQL = "select top 1 * from OrderItem where 1=1 " + strWhere; using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict))) { if (reader.Read()) { obj = GetEntityFromrdr(reader); } } return(obj); }
public OrderItemEntity SaveOrder(OrderItemEntity cartItemEntity) { dbContext.Entry(cartItemEntity).Reference(x => x.Product).IsModified = false; //dbContext.Entry(cartItemEntity).Reference(x => x.ProductSpecific.Product).IsModified = false; dbContext.Entry(cartItemEntity).Reference(x => x.Order).IsModified = false; // dbContext.CartItems.Add(cartItemEntity); dbContext.SaveChanges(); if (cartItemEntity.Deleted == true) { dbContext.Remove(cartItemEntity); } return(cartItemEntity); }
public CustomOrderItem toCustomOrderItem(OrderItemEntity orderItemEntity) { CustomOrderItem csi = new CustomOrderItem(); Product2DAO product2DAO = new Product2DAO(); csi.productID = orderItemEntity.ProductId; Product2 productItem = product2DAO.getProduct(csi.productID); //csi.productImg = productItem.Images[0].Image; csi.productName = productItem.Name; csi.pricePerOne = (double)productItem.OriginalPrice; csi.quatity = orderItemEntity.Quantity; csi.priceAll = csi.computePriceAllByProduct(); return(csi); }
public async Task RemoveOrderItemAsync(Guid orderItemId, CancellationToken cancellationToken = default) { using (ShoppingCartDbContext context = _dbContextFactory()) { OrderItemEntity orderItem = context.OrderItems.SingleOrDefault(a => a.Id == orderItemId); if (orderItem == null) { throw new OrderItemNotFoundException($"OrderItem with ID {orderItemId} not found"); } context.Remove(orderItem); await context.SaveChangesAsync(cancellationToken); } }
public void AssertBody( OrderItemEntity orderItemEntity, IDictionary <string, ServiceRecipientEntity> serviceRecipients, IList <OrderItemRecipientEntity> orderItemRecipients, IDictionary <string, PricingUnitEntity> pricingUnits) { var actual = ReadOrderItem(JToken.Parse(content)); var expected = ConvertToExpectedBody( orderItemEntity, serviceRecipients, orderItemRecipients, pricingUnits); actual.Should().BeEquivalentTo(expected); }