Exemplo n.º 1
0
        public ActionResult Index(int?page)
        {
            FrmViewData frm = new FrmViewData();
            int         totalCount;

            frm.Questions = _repQues.GetAllListByDate(30, page ?? 1, out totalCount);
            PaginatedList pager = new PaginatedList((page ?? 1), 30, totalCount);

            return(View(frm.WithPaging(pager)));
        }
Exemplo n.º 2
0
        public ActionResult ListeKullanici(int?page)
        {
            FrmViewData frm = new FrmViewData();
            int         totalCount;

            frm.Users = _repoUser.GetListByDate(100, page ?? 1, out totalCount);
            PaginatedList pager = new PaginatedList((page ?? 1), 100, totalCount);

            ViewBag.SiteName = _repoSet[SettingKey.SiteName];
            return(View(frm.WithPaging(pager)));
        }
Exemplo n.º 3
0
        public ActionResult Tag(string etiket, int?page)
        {
            FrmViewData frm = new FrmViewData();
            int         totalCount;

            frm.Questions = _repQues.GetListByTagName(etiket, PagerCount(), page ?? 1, out totalCount);
            PaginatedList pager = new PaginatedList((page ?? 1), PagerCount(), totalCount);

            ViewData["tag"] = etiket;
            return(View(frm.WithPaging(pager).WithTags(_repoTag.GetAll())));
        }
Exemplo n.º 4
0
        public ActionResult ListeZiyaret(int?page)
        {
            FrmViewData frm = new FrmViewData();
            int         totalCount;

            frm.QuestionVisits = _repoIst.GetList(75, page ?? 1, out totalCount);
            PaginatedList pager = new PaginatedList((page ?? 1), 75, totalCount);

            ViewBag.SiteName = _repoSet[SettingKey.SiteName];

            return(View(frm.WithPaging(pager)));
        }
Exemplo n.º 5
0
        public ActionResult Edit(long id)
        {
            FrmViewData frm = new FrmViewData();

            frm.Question        = _repoQues.GetById(id);
            frm.Question.Title  = frm.Question.Title.Replace("%t%", "'").Replace("@@", "@");;
            frm.Question.Detail = frm.Question.Detail.Replace("%t%", "'").Replace("@@", "@");;
            frm.Tags            = _repoTag.GetListByQuestionId(id);
            string[] ary = frm.Tags.Select(x => x.TagName).ToArray();
            ViewData["tagsStr"] = string.Join(",", ary);
            return(View("Sor", frm));
        }
Exemplo n.º 6
0
        public ActionResult Etiketler(int?page, string q)
        {
            FrmViewData    frm = new FrmViewData();
            int            totalCount;
            int            pageCount = 40;
            List <TagInfo> liste     = _repoTag.GetTagInfoByQuery(pageCount, page ?? 1, q, out totalCount);
            PaginatedList  pager     = new PaginatedList((page ?? 1), pageCount, totalCount);

            ViewBag.pager         = pager;
            ViewData["queryData"] = q;
            return(View(liste));
        }
Exemplo n.º 7
0
        public ActionResult Index(int?page)
        {
            FrmViewData frm = new FrmViewData();
            int         totalCount;

            frm.Questions = _repQues.GetListByDate(PagerCount(), page ?? 1, out totalCount);
            PaginatedList pager = new PaginatedList((page ?? 1), PagerCount(), totalCount);

            ViewBag.SiteName = _repoSet[SettingKey.SiteName];
            //string str = Request.ServerVariables["HTTP_REFERER"];//Request.UrlReferrer.AbsoluteUri;//Request.ServerVariables["REQUEST_URI"];

            InsertPageIstatik(0, AnaSayfaId);
            return(View(frm.WithPaging(pager).WithTags(_repoTag.GetAll())));
        }
Exemplo n.º 8
0
        private List <Question> BulBenzerSorulari <T>(FrmViewData frm)
        {
            List <Question> benzerSorular = new List <Question>();

            long[] tagIds  = frm.Tags.Select(x => x.TagId).ToArray();
            long[] tempIds = frm.Tags.Select(x => x.TagId).ToArray();
            benzerSorular = _repoQues.GetListByTag(25, tagIds).Where(x => x.QuestionId != frm.Question.QuestionId).ToList();
            int size = tagIds.Length - 1;

            for (int i = 0; i < tempIds.Length; i++)
            {
                //tagIds.SkipWhile(x => x == tagIds[tagIds.Length - (i + 1)]).ToArray();
                if (benzerSorular.Count < 25 & size > 1)
                {
                    List <List <long> > liste = PermatasyonUtil.Permutasyon <long>(tagIds.ToList(), size);
                    size = size - 1;
                    for (int j = 0; j < liste.Count; j++)
                    {
                        if (benzerSorular.Count < 25)
                        {
                            List <Question> temp = _repoQues.GetListByTag(25 - benzerSorular.Count, liste[j].ToArray()).Where(x => x.QuestionId != frm.Question.QuestionId).ToList();
                            benzerSorular.ConditionalAddRange(temp, "QuestionId");
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            if (benzerSorular.Count < 25)
            {
                for (int j = 0; j < tagIds.Length; j++)
                {
                    if (benzerSorular.Count < 25)
                    {
                        List <Question> temp = _repoQues.GetListByTag(25 - benzerSorular.Count, tagIds[j]).Where(x => x.QuestionId != frm.Question.QuestionId).ToList();
                        benzerSorular.ConditionalAddRange(temp, "QuestionId");
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(benzerSorular);
        }
Exemplo n.º 9
0
        //
        // GET: /Ara/

        public ActionResult Index(int?page, string q)
        {
            RepositoryQuestion _repQues = new RepositoryQuestion("", DbType.SqLite);
            RepositorySetting  _repoSet = new RepositorySetting("", DbType.SqLite);
            RepositoryTag      _repoTag = new RepositoryTag("", DbType.SqLite);
            int totalCount;

            if (!string.IsNullOrEmpty(q))
            {
                q = q.Replace("'", "%t%");
            }
            FrmViewData frm = new FrmViewData();

            frm.Questions = _repQues.GetListQueryByDate(q, PagerCount(), page ?? 1, out totalCount);
            PaginatedList pager = new PaginatedList((page ?? 1), PagerCount(), totalCount);

            ViewBag.SiteName      = _repoSet[SettingKey.SiteName];
            ViewData["queryData"] = q;
            return(View(frm.WithPaging(pager).WithTags(_repoTag.GetAll())));
        }
Exemplo n.º 10
0
        public ActionResult Detay(long id, string title)
        {
            FrmViewData frm = new FrmViewData();

            frm.Question = _repoQues.GetById(id);
            if (frm.Question.State == State.Yayinda)
            {
                frm.Tags    = _repoTag.GetListByQuestionId(id);
                frm.Answers = _repoAns.GetListByQuestionId(id);
                List <Question> benzerSorular = BulBenzerSorulari <long>(frm);
                frm.Questions = benzerSorular;
                User user = null;

                if (Request.IsAuthenticated)
                {
                    user = _repoUser.GetUserByEmail(HttpContext.User.Identity.Name);
                }
                long userId = 0;
                if (user == null)
                {
                    userId = 0;
                }
                else
                {
                    userId = user.UserId;
                }
                if (frm.Question.Title.ConvertWebUrl() == title)
                {
                    InsertPageIstatik(userId, id);
                }

                ViewBag.Title = frm.Question.Title;
                return(View(frm));
            }
            else
            {
                TempData["mesaj"] = "Soru yayından kaldırılmış";
                return(RedirectToAction("Succeed", "Soru"));
            }
        }
Exemplo n.º 11
0
        public ActionResult Detay(long id, string title, FormCollection frmCol, bool captchaValid)
        {
            ViewBag.isPostBack = "1";
            if (Request.IsAuthenticated)
            {
                FrmViewData frm          = new FrmViewData();
                User        user         = _repoUser.GetUserByEmail(HttpContext.User.Identity.Name);
                bool        createAnswer = true;
                if (string.IsNullOrEmpty(frmCol["description"]) || frmCol["description"].Length < 17)
                {
                    //ModelState.AddModelError("desciption", "Detaylı Açıklama Boş olamaz ve en az 10 karekter uzunluğunda olması gerekli");
                    ModelState.AddModelError("", "Detaylı Açıklama boş olamaz ve en az 10 karekter uzunluğunda olması gerekli");
                    createAnswer = false;
                }

                //if (!captchaValid)
                //{
                //    ModelState.AddModelError("valid", "Doğrulama kodu yanlış.");
                //    createAnswer = false;
                //}
                if (createAnswer)
                {
                    Answer answer = new Answer();
                    answer.BestReply  = false;
                    answer.Date       = DateTime.Now;
                    answer.IPAddress  = GetIpAddress();
                    answer.Reply      = frmCol["description"].Replace("'", "%t%").Replace("@", "@@");
                    answer.State      = State.Yayinda;
                    answer.User       = user;
                    answer.UserId     = user.UserId;
                    answer.QuestionId = id;
                    _repoAns.Insert(answer);
                }
                frm.Question = _repoQues.GetById(id);
                frm.Tags     = _repoTag.GetListByQuestionId(id);
                frm.Answers  = _repoAns.GetListByQuestionId(id);
                List <Question> benzerSorular = BulBenzerSorulari <long>(frm);
                frm.Questions = benzerSorular;

                ViewBag.Title = frm.Question.Title;
                return(View(frm));
            }
            else
            {
                bool createUser = true;
                if (string.IsNullOrEmpty(frmCol["description"]) || frmCol["description"].Length < 17)
                {
                    //ModelState.AddModelError("desciption", "Detaylı Açıklama Boş olamaz ve en az 10 karekter uzunluğunda olması gerekli");
                    ModelState.AddModelError("", "Detaylı Açıklama boş olamaz ve en az 10 karekter uzunluğunda olması gerekli");
                    createUser = false;
                }
                ValiDateUser(frmCol, ref createUser);
                if (!captchaValid)
                {
                    ModelState.AddModelError("valid", "Doğrulama kodu yanlış");
                    ModelState.AddModelError("", "Doğrulama kodu yanlış");
                    createUser = false;
                }
                if (createUser)
                {
                    User user = new Models.User();
                    user.Email       = frmCol["RegisterModel.Email"];
                    user.RoleId      = Role.Member.RoleId;
                    user.Name        = frmCol["RegisterModel.UserName"];
                    user.Password    = frmCol["RegisterModel.Password"];
                    user.PicturePath = new FrmBlog.Avatar.Avatar().GetRandomAvatar();
                    _repoUser.Insert(user);
                    IFormsAuthentication auth = new FormsAuthenticationWrapper();
                    auth.SetAuthCookie(user.Email, true);

                    Answer answer = new Answer();
                    answer.BestReply  = false;
                    answer.Date       = DateTime.Now;
                    answer.IPAddress  = GetIpAddress();
                    answer.Reply      = frmCol["description"].Replace("'", "%t%");
                    answer.State      = State.Yayinda;
                    answer.User       = _repoUser.GetUserByEmail(user.Email);
                    answer.UserId     = answer.User.UserId;
                    answer.QuestionId = id;
                    _repoAns.Insert(answer);
                }
                FrmViewData frm = new FrmViewData();
                frm.Question = _repoQues.GetById(id);
                frm.Tags     = _repoTag.GetListByQuestionId(id);
                frm.Answers  = _repoAns.GetListByQuestionId(id);
                List <Question> benzerSorular = BulBenzerSorulari <long>(frm);
                frm.Questions = benzerSorular;
                ViewBag.Title = frm.Question.Title;
                return(RedirectToAction("Detay", new { id = id, title = title }));
            }
        }