예제 #1
0
        private Comments CreateComment(ExamContext context, AddCommentDTO commentJson, Users user)
        {
            Comments newComment = new Comments()
            {
                Text = commentJson.Text,
            };

            newComment.PostDate = DateTime.Now;
            newComment.CommentedBy = user;
            context.Comments.Add(newComment);
            context.SaveChanges();
            return newComment;
        }
예제 #2
0
 private static LoginResponseDTO CreateResponseLogin(Users foundUser, string sessionKey)
 {
     LoginResponseDTO user = new LoginResponseDTO()
     {
         DisplayName = foundUser.DisplayName,
         Sessionkey = sessionKey,
     };
     return user;
 }
예제 #3
0
        private string AddSessionKey(ExamContext context, Users foundUser)
        {
            string sessionKey = this.GenerateSessionKey(foundUser.Id);
            foundUser.SessionKey = sessionKey;

            context.Entry(foundUser).State = System.Data.EntityState.Modified;
            context.SaveChanges();
            return sessionKey;
        }
예제 #4
0
        private static Users CreateNewUSer(UserRegisterDTO userJSON, ExamContext context)
        {
            // when the user is created
            Users createdUser = new Users()
            {
                DisplayName = userJSON.DisplayName,
                Username = userJSON.Username,
                AuthCode = userJSON.AuthCode,
            };
            //we can make sessionkey

            context.Users.Add(createdUser);
            context.SaveChanges();
            return createdUser;
        }