protected override void OnValidate()
        {
            var items = _orderItemDataProxy.GetByOrderCommand(_orderID).Execute().Value;

            if (items.Any(i => i.OrderStatus() is ShippedState))
            {
                Invalidate("This order cannot change because it has items that have been shipped");
            }
        }
Ejemplo n.º 2
0
        public override IEnumerable <ValidationResult> GetErrors()
        {
            var rule = _orderID.CreateValueRequiredRule("order id").Validate();

            if (!rule.IsValid)
            {
                yield return(new ValidationResult(rule.ErrorMessage));
            }
            else
            {
                CurrentOrderItems = _orderItemService.GetByOrderCommand(_orderID).Execute().Value;
                var errors = CurrentOrderItems.SelectMany(i => _orderItemService.DeleteCommand(i.ID).GetErrors());
                foreach (var error in errors)
                {
                    yield return(error);
                }
            }
        }
Ejemplo n.º 3
0
        public ActionResult Submit(long id)
        {
            var vm = new OrderViewModel {
                ID = id
            };
            var submittableItems = _orderItemService.GetByOrderCommand(id)
                                   .Execute()
                                   .Value
                                   .Where(i => i.OrderStatus().CanSubmit);

            foreach (var item in submittableItems)
            {
                var result = _orderItemService.SubmitCommand(item.ID).Execute();
                if (!result.Success)
                {
                    return(HandleFailedResult(ConfigureVM(vm), result));
                }
            }

            return(RedirectToAction("Edit", "Orders", new { id = id }));
        }