コード例 #1
0
        public OrderNumberComponents GetOrderNumberInfo(int customerId, int officeId, bool shouldEnumerateOrder)
        {
            var customer = GetAny <Customer>(x => x.Id == customerId).SingleOrDefault();

            if (customer == null)
            {
                throw new InvalidOperationException(string.Format("Customer ID {0} no found", customerId));
            }

            string customerCode = customer.Code;

            var office = GetAny <Office>(x => x.Id == officeId).SingleOrDefault();

            if (office == null)
            {
                throw new InvalidOperationException(string.Format("Office ID {0} no found", officeId));
            }

            int    number        = GetNextNumber(customer, officeId);
            string officeCode    = office.Code;
            bool   useOfficeCode = customer.UseOfficeCode;

            var result = new OrderNumberComponents
            {
                CustomerCode  = customerCode,
                Number        = number,
                OfficeCode    = officeCode,
                PostFix       = "",
                useOfficeCode = useOfficeCode
            };

            return(result);
        }
コード例 #2
0
        public Order AssignNumber(Order order, int?desiredNumber, string numberPostfix, bool shouldEnumerateOrder = true)
        {
            if (order == null)
            {
                throw new ArgumentNullException("order");
            }
            var customerId = order.CustomerId;
            var officeId   = order.OfficeId;

            OrderNumberComponents orderNumberInfo = Repository.GetOrderNumberInfo(customerId, officeId, shouldEnumerateOrder);

            if (desiredNumber.HasValue && shouldEnumerateOrder)
            {
                orderNumberInfo.Number = desiredNumber.Value;
            }

            order.Number = (desiredNumber.HasValue && shouldEnumerateOrder) ? desiredNumber.Value : orderNumberInfo.Number;
            order.Name   = OrderNameMaker.MakeNumber(orderNumberInfo);

            return(order);
        }
コード例 #3
0
 public string MakeNumber(OrderNumberComponents orderNumberInfo)
 {
     return(MakeNumber(orderNumberInfo.CustomerCode, orderNumberInfo.OfficeCode, orderNumberInfo.useOfficeCode, orderNumberInfo.Number, orderNumberInfo.PostFix));
 }