private void FillOrderNo(EntityEntry entry)
        {
            IOrderEntity order = entry.Entity as IOrderEntity;

            if (order == null || entry.State != EntityState.Added || !string.IsNullOrEmpty(order.OrderNo))
            {
                return;
            }

            string   key  = order.GetType().FullName;
            CodeSeed seed = this.Set <CodeSeed>().Where(x => x.SeedNo == key).FirstOrDefault();

            if (seed == null)
            {
                throw new BusinessException(GlobalConstants.EXCEPTION_CODE_DATA_NOT_FOUND, $"没有为{key}配置CodeSeed!");
            }

            lock (typeof(ImmsDbContext))
            {
                int prefixLength = seed.Prefix.Length;
                order.OrderNo = seed.Prefix + (seed.InitialValue.ToString() + seed.Postfix).PadLeft(seed.TotalLength - prefixLength, '0');

                seed.InitialValue      += 1;
                this.Attach(seed).State = EntityState.Modified;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Insert an order entity into the database
        /// </summary>
        /// <param name="createOrderEntity">The CreateOrderEntity instance insert</param>
        /// <returns>A CreateOrderEntity</returns>
        public IOrderEntity Insert(IOrderEntity createOrderEntity)
        {
            var existingOrders = GetOrders(createOrderEntity.Client);

            if (existingOrders.Count > 0)
            {
                ValidateOrder(existingOrders);
            }


            createOrderEntity.OrderId = Guid.NewGuid();
            return(createOrderEntity);
        }
Beispiel #3
0
 public ShopService(IProductService productService, IOrderEntity orderEntity, IItemEntity itemEntity)
 {
     ProductService = productService;
     OrderEntity    = orderEntity;
     ItemEntity     = itemEntity;
 }
Beispiel #4
0
 public async Task LogAsync(IOrderEntity order) => await Task.WhenAll(this.Select(e => e.LogAsync(order)));
Beispiel #5
0
 public OrderModel(IOrderEntity orderEntity)
 {
     _orderEntity = orderEntity;
 }
 public OrderService(IOrderEntity entity)
 {
     this.entity = entity;
 }
 public OrderDetailService(IOrderDetailEntity entity, IOrderEntity orderentity)
 {
     this.entity = entity;
        this.orderentity = orderentity;
 }