public IActionResult GetInterfaceLanguages()
 {
     return(es.Execute(() =>
     {
         List <Language> result = dataService.GetInterfaceLanguages();
         return new JsonResult(new GenericResult(result));
     }, false));
 }
        public void Process(
            Definition.Process definition,
            string trace,
            bool pass
            )
        {
            IExecutionService service = new ExecutionService();
            var process = definition.New(null);

            service.Execute(process);

            var index = 0;

            foreach (var c in trace)
            {
                var input = process.Processes
                            .OfType <LabelledInput <char> >()
                            .FirstOrDefault(
                    i =>
                    i.Label == c &&
                    i.Status == Status.AwaitIO);

                if (index == trace.Length - 1 && !pass)
                {
                    Assert.That(input, Is.Null);
                }

                else
                {
                    Assert.That(input, Is.Not.Null);
                    input.ExecuteInput(service);
                }
                index++;
            }
        }
Beispiel #3
0
 public IActionResult AddContactUsMessage([FromBody] Message message)
 {
     return(es.Execute(() =>
     {
         long id = messagesService.AddContactUsMessage(message);
         return new JsonResult(new GenericResult(id));
     }, false));
 }
Beispiel #4
0
        public IActionResult RegisterVisit([FromBody] Visit visit)
        {
            return(es.Execute(
                       () =>
            {
                if (visit == null || us.Empty(visit.Route))
                {
                    es.ThrowException("Wrong visit data");
                }
                visit.RequestIp = httpContext.HttpContext.Connection.RemoteIpAddress.ToString();
                visit.RequestTime = DateTimeOffset.UtcNow;
                ds.RegisterVisit(visit);

                return new JsonResult(new GenericResult());
            },
                       false
                       ));
        }
Beispiel #5
0
        public IActionResult LoginUser([FromBody] LoginData loginData)
        {
            return(es.Execute(
                       () =>
            {
                Account account = accountService.LogAccountIn(loginData);

                if (account == null)
                {
                    es.ThrowInfoException("Cannot login {0}", loginData.Login);
                }
                if (account.Locked)
                {
                    es.ThrowInfoException("Account {0} is locked", account.Login);
                }

                return new JsonResult(new GenericResult(account));
            },
                       false
                       ));
        }
Beispiel #6
0
        public IActionResult GetPage([FromBody] JObject data)
        {
            if (data == null)
            {
                return(new JsonResult(new GenericResult()));
            }

            string login = data["login"].ToString();
            string page  = data["page"].ToString();

            bool refreshCache = false;
            bool tmp          = false;

            if (bool.TryParse(data["refreshCache"].ToString(), out tmp))
            {
                refreshCache = tmp;
            }

            return(es.Execute(() =>
            {
                Page result = ps.GetFullPage(accountService.Login, login, page, refreshCache);

                if (result == null)
                {
                    // A user will be redirected to 404
                    return new JsonResult(new GenericResult());
                }

                return new JsonResult(new GenericResult(result));
            }, false));
        }
        public void CanExecutePrisoner()
        {
            Prisoner lastPrisoner = _executionService.Execute(3, 10);

            Assert.IsNotNull(lastPrisoner);
        }