Пример #1
0
        public ActionResult AssignOrder(string orderId, string managerId)
        {
            var model = new HomeOrderMonitorViewModel();

            try
            {
                var orders = ReadModel.GetInProgressOrders().ToArray();
                var managers = ReadModel.GetManagers().ToArray();
                if (!ReadModel.GetInProgressOrders().Any(o => o.OrderId == orderId))
                {
                    model.Result = HomeOrderMonitorViewModel.OperationResult.Ko;
                    model.OperationMessage = string.Format("Order '{0}' not exists.", managerId);
                    return View("OrderMonitor", model);
                }
                if (!ReadModel.GetManagers().Any(m => m.Id == managerId))
                {
                    model.Result = HomeOrderMonitorViewModel.OperationResult.Ko;
                    model.OperationMessage = string.Format("Manager '{0}' not exists.", managerId);
                    return View("OrderMonitor", model);
                }

                this.Bus.Publish(new ValidateOrder(Guid.Parse(managerId), Guid.Parse(orderId)));

                model.Result = HomeOrderMonitorViewModel.OperationResult.Ok;
                this.ReadModel.GetInProgressOrders().ForEach(model.InProgressOrders.Add);
                this.ReadModel.GetAcceptedOrders().ForEach(model.AcceptedOrders.Add);
                this.ReadModel.GetRejectedOrders().ForEach(model.RejectedOrders.Add);
                this.ReadModel.GetManagers().ForEach(model.AvailableManagers.Add);
            }
            catch
            {
                model.Result = HomeOrderMonitorViewModel.OperationResult.Ko;
                model.OperationMessage = "Assign order cannot be submitted. Please, retry later.";
                return View("OrderMonitor", model);
            }

            return View("OrderMonitor", model);
        }
Пример #2
0
        public ActionResult OrderMonitor()
        {
            var model = new HomeOrderMonitorViewModel();
            this.ReadModel.GetInProgressOrders().ForEach(model.InProgressOrders.Add);
            this.ReadModel.GetAcceptedOrders().ForEach(model.AcceptedOrders.Add);
            this.ReadModel.GetRejectedOrders().ForEach(model.RejectedOrders.Add);
            this.ReadModel.GetManagers().ForEach(model.AvailableManagers.Add);

            return View("OrderMonitor", model);
        }