Exemplo n.º 1
0
 public TimeEntry GetOpenSession()
 {
     return(CurrentOpenSession = repo.Fetch <TimeEntry>()
                                 .FirstOrDefault(x =>
                                                 x.EntryTimeStart.HasValue &&
                                                 x.EntryTimeStart.Value.Date == DateTime.Now.Date &&
                                                 !x.EntryTimeEnd.HasValue));
 }
Exemplo n.º 2
0
 public IEnumerable <Order> GetAll()
 {
     using (var db = new LiteRepository(connectionString))
     {
         return(db.Fetch <Order>());
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Execute Query[T].Where(query).ToList();
 /// </summary>
 public List <T> Fetch <T>(Expression <Func <T, bool> > predicate, string collectionName = null)
 {
     using (var db = new LiteRepository(_configService.ConnectionString))
     {
         return(db.Fetch <T>(predicate, collectionName));
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Execute Query[T].Where(query).ToList();
 /// </summary>
 public List <T> Fetch <T>(Query query = null, string collectionName = null)
 {
     using (var db = new LiteRepository(_configService.ConnectionString))
     {
         return(db.Fetch <T>(query, collectionName));
     }
 }
Exemplo n.º 5
0
 private IEnumerable <TModel> AllRecords(Expression <Func <TModel, bool> > predicate)
 {
     using (var db = new LiteRepository(_connectionString))
     {
         return(db.Fetch(predicate).Where(x => !x.Removed));
     }
 }
Exemplo n.º 6
0
        private static List <PdfFile> GetPdfsByPath(this LiteRepository repo, string path)
        {
            var lPath = path.ToLowerInvariant();

            // attention: this just works because there exists an LOWER(Path) index, as otherwise it would compare SoMeString against somestring
            // if one would add a lower function here to the left the index would not be used
            return(repo.Fetch <PdfFile>(p => p.Path == lPath));
        }
Exemplo n.º 7
0
        private async Task <List <User> > PermissionCheck(SimplePermissionType type)
        {
            var list = new List <User>();

            foreach (var user in _db.Fetch <User>())
            {
                var claimsPrincipal = await _factory.CreateAsync(user);

                var notify = (await _authorization.AuthorizeAsync(claimsPrincipal, null,
                                                                  SimplePermissionRequirement.For(type))).Succeeded;
                if (notify)
                {
                    list.Add(user);
                }
            }

            return(list);
        }
Exemplo n.º 8
0
        public Result <List <T> > Fetch(Query query = null, string collectionName = null)
        {
            var result = new Result <List <T> >();

            try
            {
                result.ResultObject = _liteRepository.Fetch <T>(query, collectionName);
            }
            catch (Exception ex)
            {
                result.ResultCode         = (int)ResultStatusCode.InternalServerError;
                result.ResultMessage      = "Hata Oluştu => " + ex;
                result.ResultInnerMessage = "Hata Oluştu => " + ex.InnerException;

                result.ResultStatus = false;
            }

            return(result);
        }
Exemplo n.º 9
0
 public Optional <IEnumerable <User> > GetUsers()
 {
     using (var repository = new LiteRepository(_connectionStringProvider.ConnectionString))
     {
         var entities = repository.Fetch <User>();
         return(entities.Count == 0 ?
                Optional <IEnumerable <User> > .Empty() :
                Optional <IEnumerable <User> > .For(entities));
     }
 }
Exemplo n.º 10
0
        private static List <WordAnnotation> GetAnnotations(this LiteRepository repo, string contentMd5)
        {
            var pdf = repo.GetPdf(contentMd5);

            if (pdf == null)
            {
                return(null);
            }
            return(repo.Fetch <WordAnnotation>(wa => wa.Document.Id == pdf.Id));
        }
Exemplo n.º 11
0
        private static void PrintPersons(LiteRepository liteRepository)
        {
            IEnumerable <Person> persons = liteRepository.Fetch <Person>()
                                           .OrderBy(person => person.Name);

            foreach (Person person in persons)
            {
                Console.WriteLine("{0}, {1} years old", person.Name, person.Age);
            }
        }
Exemplo n.º 12
0
        public async Task <Player> JoinGameSession(string userName, string joinCode)
        {
            GameSession session;

            try
            {
                session = _db.Single <GameSession>(gs => gs.JoinCode == joinCode);
            }
            catch (InvalidOperationException)
            {
                return(null);
            }

            var id = _db.Insert(new Player {
                Name = userName, GameSession = session
            });
            await Groups.AddToGroupAsync(Context.ConnectionId, "Players" + joinCode);

            await Clients.Groups("Players" + session.JoinCode, "Server" + session.JoinCode)
            .SendAsync("PlayerCountUpdated", _db.Fetch <Player>().Count(p => p.GameSession.Id == session.Id));

            return(_db.SingleById <Player>(id));
        }
Exemplo n.º 13
0
 public void SeedDefaultUserIfEmpty()
 {
     if (_instance.Fetch <UserModel>().Count == 0)
     {
         Create(new UserModel
         {
             FirstName = "System",
             Id        = Guid.NewGuid(),
             LastName  = "Administrator",
             Username  = "******",
             Password  = "******"
         });
     }
 }
Exemplo n.º 14
0
        public void AddTrades(IEnumerable <Trade> trades, out List <Trade> newTrades)
        {
            newTrades = new List <Trade>();
            _log.LogInformation("Adding new trades to database");

            foreach (var trade in trades)
            {
                var singleOrDefault = _db.Fetch <Trade>().SingleOrDefault(x => x.Id == trade.Id);
                if (singleOrDefault == null)
                {
                    _db.Insert(trade);
                    newTrades.Add(trade);
                }
            }

            _log.LogInformation($"Added {newTrades.Count} new trades to database");
        }
Exemplo n.º 15
0
        private static async void LeaderBoards(int currentSessionId, LiteRepository db, IHubCallerClients clients,
                                               ILogger log)
        {
            log.LogWarning("Showing Leaderboards");
            var currentSession = db.SingleById <GameSession>(currentSessionId);
            var leaderboard    = from player in db.Fetch <Player>()
                                 where player.GameSession.Id.Equals(currentSessionId)
                                 orderby player.Score descending
                                 select player;
            await clients.Groups("Players" + currentSession.JoinCode, "Server" + currentSession.JoinCode)
            .SendAsync("CurrentLeaderboard", leaderboard.ToList());

            await Task.Delay(TimeSpan.FromSeconds(10));

            if (currentSession.CurrentQuestionIndex < currentSession.Questionnaire.Questions.Count)
            {
                NextQuestion(currentSessionId, db, clients, log);
            }
        }
Exemplo n.º 16
0
 public List <Person> Select(string query) => repository.Fetch <Person>(x => x.Name.ToLower().Contains(query.ToLower()));
Exemplo n.º 17
0
    public void StartSession()
    {
        //todo:will check if there is an entry for today. if there is then it will not insert new data entry.
        var result    = dataSave.StartTimer().Wait();
        var timeEntry = repo.Fetch <TimeEntry>().OrderBy(x => x.EntryTimeStart).First();

        Assert.True(timeEntry.EntryTimeStart.HasValue && !timeEntry.EntryTimeEnd.HasValue, "added wrong data");
        Assert.True((timeEntry.EntryTimeStart.Value - DateTime.Now).Seconds < 2, "too much time passed between start and test.");
        Assert.True(result == OperationResult.OK);
    }
Exemplo n.º 18
0
        public ActionResult Index()
        {
            var users = _db.Fetch <User>(collectionName: "users").ToList();

            return(View(users));
        }
        public void SeedDatabase()
        {
            while (_db.Database.GetCollectionNames().Any())
            {
                _db.Database.DropCollection(_db.Database.GetCollectionNames().First());
            }



            var question1 = _db.Insert(new Question
            {
                Content      = "Hvem af disse personer deltog i krigen ved dybbøl?",
                Points       = 700,
                QuestionType = QuestionType.Text,
                Time         = TimeSpan.FromSeconds(30)
            });

            var question2 = _db.Insert(new Question
            {
                Content      = "Hvem af disse personer døde i krigen ved dybbøl?",
                Points       = 500,
                QuestionType = QuestionType.Text,
                Time         = TimeSpan.FromSeconds(30)
            });

            var questionnaire1 = _db.Insert(new Questionnaire
            {
                Title     = "Broager i 1864",
                Questions = new List <Question>()
                {
                    _db.SingleById <Question>(question1), _db.SingleById <Question>(question2)
                }
            });
            var x = _db.Fetch <Questionnaire>();

            var question3 = _db.Insert(new Question
            {
                Content      = "Hvor stor var Broager i Bronzealderen?",
                Points       = 600,
                QuestionType = QuestionType.Text,
                Time         = TimeSpan.FromSeconds(30)
            });
            var question4 = _db.Insert(new Question
            {
                Content      = "Hvor mange boede i broager i Bronzealderen?",
                Points       = 400,
                QuestionType = QuestionType.Text,
                Time         = TimeSpan.FromSeconds(30)
            });

            var questionnaire2 = _db.Insert(new Questionnaire
            {
                Title     = "Broager i Bronzealderen",
                Questions = new List <Question>()
                {
                    _db.SingleById <Question>(question3), _db.SingleById <Question>(question4)
                }
            });

            _db.Insert(new Answer
            {
                Options = new List <string>
                {
                    "Henrik",
                    "Peter",
                    "Lise",
                    "Lars"
                },
                CorrectAnswer = "Henrik",
                AnswerType    = QuestionType.Text,
                Question      = _db.SingleById <Question>(question1)
            });
            _db.Insert(new Answer
            {
                Options = new List <string>
                {
                    "Hansen",
                    "Peter",
                    "Henrik",
                    "Ludvig"
                },
                CorrectAnswer = "Henrik",
                AnswerType    = QuestionType.Text,
                Question      = _db.SingleById <Question>(question2)
            });
            _db.Insert(new Answer
            {
                Options = new List <string>
                {
                    "10 km2",
                    "15 km2",
                    "20 km2",
                    "30 km2"
                },
                CorrectAnswer = "15 km2",
                AnswerType    = QuestionType.Text,
                Question      = _db.SingleById <Question>(question3)
            });
            _db.Insert(new Answer
            {
                Options = new List <string>
                {
                    "100",
                    "200",
                    "500",
                    "350"
                },
                CorrectAnswer = "350",
                AnswerType    = QuestionType.Text,
                Question      = _db.SingleById <Question>(question4)
            });

            _db.Insert(new GameSession
            {
                Questionnaire = _db.SingleById <Questionnaire>(questionnaire1),
                StartTime     = DateTime.Now,
                JoinCode      = "abcde"
            });
            _db.Insert(new GameSession
            {
                Questionnaire = _db.SingleById <Questionnaire>(questionnaire2),
                StartTime     = DateTime.Now,
                JoinCode      = "12345"
            });
        }
Exemplo n.º 20
0
        public ActionResult Index()
        {
            var tags = db.Fetch <Tag>();

            return(View(tags));
        }
Exemplo n.º 21
0
 public IList <T> Fetch(Expression <Func <T, bool> > predicate)
 {
     return(_liteRepository.Fetch(predicate));
 }
Exemplo n.º 22
0
 public IEnumerable <Questionnaire> Get()
 {
     return(_db.Fetch <Questionnaire>());
 }
Exemplo n.º 23
0
 public List <ServiceModel> GetAll()
 {
     return(_instance.Fetch <ServiceModel>());
 }
Exemplo n.º 24
0
 public List <AuditEntryBase> GetAll()
 {
     return(db.Fetch <AuditEntryBase>().OrderByDescending(a => a.Time).ToList());
 }
        public IEnumerable <User> GetAll()
        {
            var users = Repository.Fetch <User>();

            return(users);
        }
Exemplo n.º 26
0
 public IEnumerable <Answer> Get()
 {
     return(_db.Fetch <Answer>());
 }
Exemplo n.º 27
0
 public List <Poster> ReadByPersonId(string personId) => repository.Fetch <Poster>(x => x.PersonId == personId);
Exemplo n.º 28
0
        public ActionResult AdminView()
        {
            var events = _db.Fetch <Event>();

            return(View(events));
        }