Exemplo n.º 1
0
 //constructor
 public MessageListViewModel()
 {
     using (QAContext ctx = new QAContext())
     {
         this.MessageList = ctx.Message.ToList();
     }
 }
Exemplo n.º 2
0
        public IQueryable <Answer> GetAnswers([QueryString("UserId")] int?userId)
        {
            var dbContext             = new QAContext();
            IQueryable <Answer> query = dbContext.Answers;

            if (userId.HasValue && userId > 0)
            {
                query = query.Where(a => a.AuthorId == userId.Value);

                // sorting or filtering
                switch (AnswerSortValue.Value)
                {
                case "newest":
                    query = query.OrderByDescending(a => a.CreateDate);
                    break;

                case "votes":
                    query = query.OrderByDescending(a => a.Votes.Sum(v => v.VoteValue))
                            .ThenByDescending(a => a.CreateDate);
                    break;
                }

                AnswerSortButtons.Visible = query.Count() > 1;
            }
            else
            {
                query = null;
            }

            return(query);
        }
        public IQueryable <Answer> GetAnswers([QueryString("QuestionID")] int?questionId)
        {
            var dbContext             = new QAContext();
            IQueryable <Answer> query = dbContext.Answers;

            if (questionId.HasValue && questionId > 0)
            {
                query = query.Where(a => a.QuestionId == questionId.Value);

                // sort
                if (AnswersSortValue.Value == "oldest")
                {
                    query = query.OrderBy(a => a.CreateDate);
                }
                else
                {
                    query =
                        query.OrderByDescending(a => a.IsAccepted)
                        .ThenByDescending(a => a.Votes.Sum(v => v.VoteValue))
                        .ThenBy(a => a.CreateDate);
                }
            }
            else
            {
                query = null;
            }

            return(query);
        }
Exemplo n.º 4
0
        public IQueryable <Question> GetQuestions([QueryString("search")] string search)
        {
            var dbContext = new QAContext();
            IQueryable <Question> query = dbContext.Questions;

            // search
            if (!string.IsNullOrEmpty(search))
            {
                search = HttpUtility.UrlDecode(search);
                query  = query.Where(q => q.Title.Contains(search) || q.Body.Contains(search));
            }

            // sorting or filtering
            switch (QuestionSortValue.Value)
            {
            case "newest":
                query = query.OrderByDescending(q => q.CreateDate);
                break;

            case "votes":
                query = query.OrderByDescending(q => q.Votes.Sum(v => v.VoteValue))
                        .ThenByDescending(q => q.Answers.Any(a => a.IsAccepted))
                        .ThenByDescending(q => q.Answers.Count)
                        .ThenByDescending(q => q.CreateDate);
                break;

            case "unanswered":
                query = query.Where(q => q.Answers.Count == 0).OrderByDescending(q => q.CreateDate);
                break;
            }

            return(query);
        }
Exemplo n.º 5
0
        private EEContext CreateContext(string userId, LUInfo luInfo)
        {
            EEContext context;
            string    intent = luInfo.Intent.intent;

            if (intent == "DoExam")
            {
                context = examCStore.GetContext(userId);
                if (context == null)
                {
                    context = new ExamContext(userId);
                }
            }
            else if (intent == "IntelligenceRoute")
            {
                context = irCStore.GetContext(userId);
                if (context == null)
                {
                    context = new IRContext(userId);
                }
            }
            else
            {
                context = new QAContext(userId, intent, luInfo.EntityList);
            }

            return(context);
        }
Exemplo n.º 6
0
        public string HandleMessage(string userId, string userInput, ref EEContext eContext)
        {
            QAContext context = (QAContext)eContext;

            string answer = this.mapper.GetResponse(userId, userInput, context);

            return(answer);
        }
Exemplo n.º 7
0
 public void SaveRecognizedNotes(string notes)
 {
     using (QAContext context = new QAContext())
     {
         var rep = new Repository(context);
         rep.SaveNotes(notes);
     }
 }
Exemplo n.º 8
0
 public string GetHandWritingNotes(string groupKey)
 {
     using (QAContext context = new QAContext())
     {
         var rep = new Repository(context);
         return(rep.GetHandWritingNote(groupKey));
     }
 }
Exemplo n.º 9
0
 public List <string> GetAllHandWritingNote()
 {
     using (QAContext context = new QAContext())
     {
         var rep = new Repository(context);
         return(rep.GetHandWritingNote());
     }
 }
Exemplo n.º 10
0
 public List <HandWritingNoteDTO> GetHandWritingNotes()
 {
     using (QAContext context = new QAContext())
     {
         var rep = new Repository(context);
         return(rep.GetHandWrittenNotes());
     }
 }
Exemplo n.º 11
0
 public string GetRecognizedNotes()
 {
     using (QAContext context = new QAContext())
     {
         var rep = new Repository(context);
         return(rep.GetRecognizedNotes());
     }
 }
Exemplo n.º 12
0
        private void BindUserData(int userId)
        {
            var dbContext = new QAContext();
            var user      = dbContext.Users.Single(u => u.Id == userId);

            Title = UserFullName.InnerText = user.FullName;

            FirstNameTextBox.Text = user.FirstName;
            LastNameTextBox.Text  = user.LastName;
        }
Exemplo n.º 13
0
        public User GetUser()
        {
            var dbContext           = new QAContext();
            var userIdentity        = HttpContext.Current.User.Identity;
            IQueryable <User> query = dbContext.Users;

            query = userIdentity.IsAuthenticated ? query.Where(u => u.Email == userIdentity.Name) : null;

            return(query?.Single());
        }
Exemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dbContext = new QAContext();
            int userId;

            if (int.TryParse(Request.QueryString["UserId"], out userId) && userId > 0)
            {
                var user = dbContext.Users.SingleOrDefault(u => u.Id == userId);
                Title = user?.FullName ?? "Untitled";
            }
        }
Exemplo n.º 15
0
 public void SaveHandwritingNotes(string notes)
 {
     using (QAContext context = new QAContext())
     {
         var rep  = new Repository(context);
         var note = new HandWritingNoteDTO {
             Notes = notes
         };
         rep.SaveHandWrittenNotes(note);
     }
 }
Exemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dbContext = new QAContext();
            int questionId;

            if (int.TryParse(Request.QueryString["QuestionID"], out questionId) && questionId > 0)
            {
                var question = dbContext.Questions.SingleOrDefault(q => q.Id == questionId);
                Title = question?.Title ?? "Untitled";
            }

            if (IsPostBack)
            {
                ErrorDiv.Visible = false;
            }
        }
Exemplo n.º 17
0
        public string GetResponse(string userId, string userInput, QAContext context)
        {
            string intent = context.intent;//luInfo.intent;

            if (string.IsNullOrWhiteSpace(intent))
            {
                return(null);
            }

            QueryMapInfo info = iStore.GetMapInfo(intent.ToLower());

            if (info != null)
            {
                if (info.qaType == QAType.Direct)
                {
                    return(info.answer);
                }
                else if (info.qaType == QAType.File)
                {
                    string path   = info.answer;
                    string answer = Utils.Utils.ReadEmbeddedResourceFile(path);
                    return(answer);
                }
                else //if (info.qaType == QAType.SQLQuery)
                {
                    if (string.IsNullOrWhiteSpace(info.answer))
                    {
                        return("");
                    }

                    string     className  = info.answer;
                    Type       type       = Type.GetType(className);
                    Object     obj        = Activator.CreateInstance(type);
                    MethodInfo methodInfo = type.GetMethod("GetResponse");

                    object[] parametersArray = new object[] { userId, intent, context.entities };

                    string respStr = (string)methodInfo.Invoke(obj, parametersArray);

                    return(respStr);
                }
            }
            else
            {
                return(iStore.GetMapInfo("none").answer);
            }
        }
Exemplo n.º 18
0
        public IQueryable <Question> GetQuestion([QueryString("QuestionID")] int?questionId)
        {
            var dbContext = new QAContext();
            IQueryable <Question> query = dbContext.Questions;

            if (questionId.HasValue && questionId > 0)
            {
                query = query.Where(q => q.Id == questionId.Value);
            }
            else
            {
                Response.Redirect("~/");
                query = null;
            }

            return(query);
        }
Exemplo n.º 19
0
        public IQueryable <User> GetUser([QueryString("UserId")] int?userId)
        {
            var dbContext           = new QAContext();
            IQueryable <User> query = dbContext.Users;

            if (userId.HasValue && userId > 0)
            {
                query = query.Where(u => u.Id == userId.Value);
            }
            else
            {
                Response.Redirect("~/");
                query = null;
            }

            return(query);
        }
Exemplo n.º 20
0
        protected void QuestionsCountLable_OnLoad(object sender, EventArgs e)
        {
            var dbContext = new QAContext();
            IQueryable <Question> query = dbContext.Questions;
            var search = Request.QueryString["search"];
            var prefix = "";

            if (!string.IsNullOrEmpty(search))
            {
                search  = HttpUtility.UrlDecode(search);
                query   = query.Where(q => q.Title.Contains(search) || q.Body.Contains(search));
                prefix += " searched";
            }

            if (QuestionSortValue.Value == "unanswered")
            {
                query   = query.Where(q => q.Answers.Count == 0);
                prefix += " unanswered";
            }

            QuestionsCountLable.Text = query.Count().ToString("N0") + prefix;
        }
Exemplo n.º 21
0
 public QARepository(QAContext qAContext)
 {
     QAContext = qAContext;
 }
Exemplo n.º 22
0
 public QuestionRepository(QAContext QAcontext)
 {
     context = QAcontext;
 }
Exemplo n.º 23
0
 public AuthRepository()
 {
     _ctx         = new QAContext();
     _userManager = new UserManager <User>(new UserStore <User>(_ctx));
 }
Exemplo n.º 24
0
 public LeaderboardController(QAContext context)
 {
     _context = context;
 }
Exemplo n.º 25
0
 public TagsOperations()
 {
     databaseContext = new QAContext();
 }
Exemplo n.º 26
0
 public Repository(DbContext ctx)
 {
     this.ctx = (QAContext)ctx;
 }
Exemplo n.º 27
0
 public void Dispose()
 {
     _dbContext?.Dispose();
     _dbContext = null;
 }
Exemplo n.º 28
0
 public AnswerRepository(QAContext QAcontext)
 {
     context = QAcontext;
 }
Exemplo n.º 29
0
 public ProfileController(QAContext context, IHttpContextAccessor contextAccess, UserManager <ApplicationUser> um)
 {
     _caller      = contextAccess.HttpContext.User;
     _context     = context;
     _userManager = um;
 }
Exemplo n.º 30
0
 public QACategoriesController(QAContext qaContext)
 {
     _qaContext = qaContext;
 }