示例#1
0
        public bool TryConfirmOrderByAdmin(Order order, out ICollection <string> errors)
        {
            errors = new List <string>();

            //check order null
            if (order == null)
            {
                errors.Add("Order can not be empty");
                return(false);
            }

            //check product operating model
            OperatingModelService modelService = modelServiceFactory
                                                 .GetService(sellerRepository.GetProductBy(order.SellerId, order.ProductTypeId).Model);

            if (!modelService.CanAdminConfirmsOrder())
            {
                errors.Add("You don't have right to confirm this order");
            }

            //check order status
            if (order.Status != OrderStatus.Confirming)
            {
                errors.Add("Can only confirm an order while firming it");
            }

            if (!errors.Any())
            {
                order.Status = OrderStatus.Preparing;
                return(true);
            }
            return(false);
        }
示例#2
0
        public bool TryUnregister(int sellerId, int productTypeId, out ICollection <string> errors)
        {
            errors = new List <string>();

            //check product existence
            Product product = sellerRepository.GetProductBy(sellerId, productTypeId);

            if (product == null)
            {
                errors.Add("Could not found product");
                return(false);
            }

            //check if can leave this product operating model
            OperatingModelService modelService = modelServiceFactory.GetService(product.Model);

            if (modelService.CanLeaveThisModel(product, out errors))
            {
                product.Seller.UnregisterProduct(product);
                return(true);
            }
            return(false);
        }