Ejemplo n.º 1
0
        //QA modul
        public void AddQuestion(Question pitanje)
        {
            List<Tag> tags = pitanje.Tags.ToList();
            List<Category> kate = pitanje.Categories.ToList();

            string cmd = string.Format("EXEC [dbo].[usp_QuestionsInsert] '{0}',{1},'{2}','{3}','{4}',{5},{6}", pitanje.QuestionBody, pitanje.User.UserID, pitanje.CreatedDate.Value.ToString("MM/dd/yyyy H:m:s:f", CultureInfo.InvariantCulture), pitanje.GUID, pitanje.QuestionTitle, 0, 0);
            pitanje = context.Database.SqlQuery<Question>(cmd).SingleOrDefault();

            foreach (var tag in tags)
            {
                context.Database.ExecuteSqlCommand("EXEC dbo.usp_TagInQuestionInsert " + pitanje.QuestionID + "," + tag.TagID);
            }
            foreach (var cat in kate)
            {
                context.Database.ExecuteSqlCommand("EXEC [dbo].[usp_QuestionsInCategoryInsert] " + pitanje.QuestionID + "," + cat.CategoryID);
            }
        }
 public ItemPreporuka(Question q)
 {
     question = q;
 }
Ejemplo n.º 3
0
 public void Update_Question(Question q)
 {
     context.Database.ExecuteSqlCommand("EXEC [dbo].[usp_QuestionsUpdate] {0},{1},{2},{3},{4},{5},{6}", q.QuestionID, q.QuestionBody, q.User.UserID, q.CreatedDate, q.GUID, q.Likes, q.NumOfViews);
 }
Ejemplo n.º 4
0
        public Question GetQuestionZaPreporuku(User a)
        {
            List<Tag> listaTagovaLoginUsera = new List<Tag>();
            List<Category> listaKategorijaLoginUsera = new List<Category>();
            List<QuestionsRating> listaQuesionRatingLoginUsera = new List<QuestionsRating>();

            List<Question> questionsOfUser = context.Questions.Where(q => q.CreatorID == a.UserID).ToList();
            foreach (var item in questionsOfUser)
            {
                foreach (var i in item.Tags)
                {
                    listaTagovaLoginUsera.Add(i);
                }
            }
            foreach (var item in questionsOfUser)
            {
                foreach (var i in item.Categories)
                {
                    listaKategorijaLoginUsera.Add(i);
                }
            }
            foreach (var item in questionsOfUser)
            {
                foreach (var i in item.QuestionsRatings)
                {
                    listaQuesionRatingLoginUsera.Add(i);
                }
            }
            Question PitanjeVirtualno = new Question();
            PitanjeVirtualno.QuestionsRatings = listaQuesionRatingLoginUsera;
            PitanjeVirtualno.Tags = listaTagovaLoginUsera;
            PitanjeVirtualno.Categories = listaKategorijaLoginUsera;

            return PitanjeVirtualno;
        }
 private List<QuestionRecommender> GetPreporukaPitanja(Question q)
 {
     ItemPreporuka ip = new ItemPreporuka(q);
     return ip.GetQuestionsPreporke();
 }
        public ActionResult Create(string Naslov, string Content, string jsonTagQuestion, string jsonKatQuestion)
        {
            Question pitanje = new Question();
            pitanje.User = Autorizacija.Autorizacija.GetCurrentUser(this.HttpContext);
            pitanje.CreatedDate = DateTime.Now;
            pitanje.QuestionBody = Server.HtmlDecode(Content).Replace("'", "&#39;");
            pitanje.QuestionTitle = Naslov;
            pitanje.GUID = Guid.NewGuid();

            var ListaTagova = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Json.Tag>>(jsonTagQuestion);
            var ListaKategorija = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Json.Kategorija>>(jsonKatQuestion);

            List<Igman.DB.DAL.Tag> listTempTag = SinhronyzeWithDB(ListaTagova.Where(x => x.TagID == "-1").ToList(), ListaTagova.Where(x => x.TagID != "-1").ToList());
            List<Category> listaKategorija = SinhronyzeWithDB(ListaKategorija);

            pitanje.Categories = listaKategorija;
            pitanje.Tags = listTempTag;
            _db.AddQuestion(pitanje);

            return RedirectToAction("index", "Questions");
        }