コード例 #1
0
        public void UpdateScoresAndTranslation(UserPair word)
        {
            if (!File.Exists(DbFile))
            {
                return;
            }

            using (var cnn = SimpleDbConnection())
            {
                cnn.Open();
                var op =
                    $"Update words set AggregateScore =  @AggregateScore," +
                    $"PassedScore = @PassedScore, " +
                    $"Translation = @Translation," +
                    $"LastExam = @LastExam," +
                    $"AllMeanings = @AllMeanings," +
                    $"Revision = @Revision," +
                    $"Examed = @Examed where PairId = @PairId";
                cnn.Execute(op, word);
            }
        }
コード例 #2
0
        public ActionResult <Chat> ConnectToUser(UserPair userPair)
        {
            var nameClaim = _identityService.GetUsername(HttpContext);

            if (nameClaim != userPair.Username)
            {
                return(Unauthorized());
            }

            // Requester is the person that initiated the request
            User requester = _databaseContext.Users.Find(userPair.Username);
            // The connectee is the person that the requester wants to connect to
            User connectee = _databaseContext.Users.Find(userPair.ConnectTo);

            // If trying to connect nobody, it's a Bad Request
            if (requester == null)
            {
                return(BadRequest());
            }
            // If the person trying to connect to is not found, it's a Not Found
            if (connectee == null)
            {
                return(NotFound());
            }

            // Check if a one-on-one chat already exists, since those are unique.
            var existingChat = _databaseContext.Chats.FirstOrDefault(c => c.Users.Count == 2 && c.Users.All(userChat =>
                                                                                                            userChat.User.Username ==
                                                                                                            userPair.Username ||
                                                                                                            userChat.User.Username ==
                                                                                                            userPair.ConnectTo));

            if (existingChat != default)
            {
                // If it does, return the existing chat's id.
                return(default); //new Chat(existingChat, GetAllUsers(existingChat.Id).Value);
コード例 #3
0
        public UserPairForExam CreateFromBaseUserPair(UserPair userPair, User user, QuestionMetric metric)
        {
            var userPairForExam = new UserPairForExam();

            return(userPairForExam);
        }