Beispiel #1
0
        public IActionResult Events(ServiceEventsViewModel model)
        {
            if (model.OrderEvent.EventType == "-1")
            {
                ModelState.AddModelError("OrderEvent.EventType", "Please select the Event Type");
            }

            if (model.Customer.Age == false)
            {
                ModelState.AddModelError("Customer.Age", "Sorry you must not be below 21 years old");
            }

            if (model.OrderEvent.TermsAndConditions == false)
            {
                ModelState.AddModelError("OrderEvent.TermsAndConditions", "We need to see your Id");
            }


            if (ModelState.IsValid)
            {
                ViewBag.EventRequestStatus = "Thanks!";
                ModelState.Clear();
            }

            var customer   = new Customer();
            var even       = new EventHall();
            var orderEvent = new OrderEvent();
            ServiceEventsViewModel model2 = new ServiceEventsViewModel()
            {
                Customer   = customer,
                OrderEvent = orderEvent
            };

            return(View(model2));
        }
Beispiel #2
0
        public async Task Run(GameContext context, BaseWorkerWindow vm, Action <string> statusUpdater, CancellationToken cancellationToken)
        {
            await Task.CompletedTask;
            var hall         = new EventHall(context);
            var ignoredTypes = new List <Type>();

            if (!DismissBarters)
            {
                ignoredTypes.Add(typeof(BarterEvent));
            }
            if (!DismissExchanges)
            {
                ignoredTypes.Add(typeof(ExchangeEvent));
            }

            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();
                if (!hall.IsScreenActive())
                {
                    throw new InvalidOperationException("You're not at the event hall screen");
                }
                statusUpdater("Looking for active events...");
                await hall.ToggleFastBattle(true, cancellationToken);

                var events = hall.Events;
                var ev     = events.FirstOrDefault(x => !ignoredTypes.Contains(x.GetType()));

                try {
                    if (ev != null)
                    {
                        statusUpdater($"Resolving {ev.GetType().Name}...");
                        if (!await hall.ResolveEvent(ev, cancellationToken))
                        {
                            cancellationToken.ThrowIfCancellationRequested();
                            await hall.FindMoreEvents(cancellationToken);
                        }
                    }
                    else
                    {
                        statusUpdater("No events found, searching for one...");
                        await hall.FindMoreEvents(cancellationToken);
                    }
                } catch (OperationCanceledException) {
                    // prevent unintended cancellation
                }

                cancellationToken.ThrowIfCancellationRequested();
            }
        }