Example #1
0
        public virtual void ChangeOrderStatus(ConsignmentOrder entity, OrderStatus orderStatus)
        {
            if (null == entity)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            entity.OrderStatus = orderStatus;

            Update(entity);
        }
Example #2
0
        public virtual void DeleteConsignmentOrder(ConsignmentOrder entity)
        {
            if (null == entity)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            entity.TripId = null;
            consignmentOrderRepository.Update(entity);

            eventPublisher.EntityDeleted(entity);
        }
Example #3
0
        public virtual void Insert(ConsignmentOrder entity)
        {
            if (null == entity)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            entity.PaymentStatus = GetPaymentStatus(entity);

            repository.Insert(entity);

            eventPublisher.EntityInserted(entity);
        }
Example #4
0
        public virtual void Delete(ConsignmentOrder entity)
        {
            if (null == entity)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            entity.Deleted = true;
            entity.DTime   = DateTime.UtcNow;

            repository.Update(entity);

            eventPublisher.EntityDeleted(entity);
        }
Example #5
0
        public virtual void Update(ConsignmentOrder entity)
        {
            if (null == entity)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            entity.UTime         = DateTime.UtcNow;
            entity.PaymentStatus = GetPaymentStatus(entity);

            repository.Update(entity);

            eventPublisher.EntityUpdated(entity);
        }
Example #6
0
        protected virtual PaymentStatus GetPaymentStatus(ConsignmentOrder entity)
        {
            if (null == entity)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (entity.PaymentStatus == PaymentStatus.Cancelled)
            {
                return(PaymentStatus.Cancelled);
            }

            if (entity.Receivable.HasValue && entity.Receipts.HasValue)
            {
                if (entity.Receivable.Value <= entity.Receipts.Value)
                {
                    return(PaymentStatus.Paid);
                }
                else if (entity.Receipts.Value > 0)
                {
                    return(PaymentStatus.PartiallyPaid);
                }
                else
                {
                    return(PaymentStatus.Pending);
                }
            }
            else if (entity.Receivable.HasValue)
            {
                return(PaymentStatus.Pending);
            }
            else if (entity.Receipts.HasValue)
            {
                return(PaymentStatus.Paid);
            }

            return(PaymentStatus.Unknown);
        }
Example #7
0
        public virtual ConsignmentOrderModel PrepareModel(ConsignmentOrderModel model, ConsignmentOrder entity, bool excludeProperties = false)
        {
            if (null != entity)
            {
                model = model ?? entity.ToModel <ConsignmentOrderModel>();

                PrepareGoodsSearchModel(model.GoodsSearchModel, entity);
            }

            if (null == model)
            {
                model = new ConsignmentOrderModel
                {
                    SerialNum = CommonHelper.GenerateSerialNumber()
                }
            }
            ;

            PrepareModel(ref model);

            return(model);
        }
Example #8
0
        public virtual GoodsListModel PrepareGoodsListModel(GoodsSearchModel searchModel, ConsignmentOrder entity)
        {
            if (null == searchModel)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            if (null == entity)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var list = entity.Goods
                       .OrderByDescending(x => x.CTime)
                       .ToList();

            var model = new GoodsListModel
            {
                Data = list.PaginationByRequestModel(searchModel).Select(x =>
                {
                    var modelItem   = x.ToModel <GoodsModel>();
                    modelItem.CTime = dateTimeHelper.ConvertToUserTime(modelItem.CTime, DateTimeKind.Utc);

                    return(modelItem);
                }),
                Total = list.Count
            };

            return(model);
        }
Example #9
0
        protected virtual GoodsSearchModel PrepareGoodsSearchModel(GoodsSearchModel model, ConsignmentOrder entity)
        {
            if (null == model)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (null == entity)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            model.OrderId = entity.Id;
            model.SetGridPageSize();

            return(model);
        }