예제 #1
0
        //Create new user
        public async Task <ForumModel> Create(ForumModel user)
        {
            await Task.Run(() =>
                           _content.InsertOne(user));

            return(user);
        }
예제 #2
0
        public virtual IActionResult EditForum(ForumModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageForums))
            {
                return(AccessDeniedView());
            }

            //try to get a forum with the specified id
            var forum = _forumService.GetForumById(model.Id);

            if (forum == null)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                forum = model.ToEntity(forum);
                forum.UpdatedOnUtc = DateTime.UtcNow;
                _forumService.UpdateForum(forum);

                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Forums.Forum.Updated"));

                return(continueEditing ? RedirectToAction("EditForum", forum.Id) : RedirectToAction("List"));
            }

            //prepare model
            model = _forumModelFactory.PrepareForumModel(model, forum, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
 public IActionResult Question(ForumModel forumModel)
 {
     forumModel.userId = HttpContext.Session.GetInt32("UserId") ?? 0;
     forumModel.date   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     forumModel.SaveQuestion();
     return(RedirectToAction("Index", "Forum"));
 }
예제 #4
0
        /// <summary>
        /// Get Forum list
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List <ForumModel> GetForumListing(ForumModel model)
        {
            var bookingList = context.vw_GetForumList.Where(x => x.StratasBoardId == model.StratasBoardId && x.STATUS == 1).OrderByDescending(x => x.CreatedOn).ToList();
            List <ForumModel> objProjListingModel = new List <ForumModel>();

            foreach (var item in bookingList)
            {
                ForumModel objBookingList = new ForumModel
                {
                    TopicId                = item.TopicId,
                    Topic                  = item.Topic,
                    TopicContent           = item.TopicContent,
                    UploadedFileName       = item.UploadedFileName,
                    UploadedFileActualName = item.UploadedFileActualName,
                    CreatedOn              = item.CreatedOn.Value,
                    CreatedDate            = item.CreatedDate,
                    CreatedTime            = item.CreatedTime,
                    Status                 = item.STATUS.Value,
                    CreatedDateTime        = item.CreatedDateTime,
                    CreatedBy              = item.CreatedBy.Value,
                    StratasBoardId         = item.StratasBoardId.Value,
                    IsFlagged              = item.IsFlagged.Value,
                    CreatedByName          = item.CreatedByName,
                    ReplyCounter           = item.ReplyCounter.Value
                                             // FlaggedByLoggedInUser = GetFlaggedUser(item.TopicId, ClientSessionData.UserClientId)
                };
                objProjListingModel.Add(objBookingList);
            }
            return(objProjListingModel);
        }
        //文章內部得細項
        public ActionResult Detail(int?id = 10)
        {
            //接著透過cookie找出會員編號,確認讀讚人數
            if (Request.Cookies["account"] != null)
            {
                string epid  = Request.Cookies["account"].Value;
                var    EP_ID = db.tEmployee.Where(p => p.fEp_Code == epid).Single().fEp_ID;

                ViewBag.EPIP = EP_ID;
            }

            var ftID   = db.tForumTitle.Where(p => p.fMC_ID == id).First().fFT_ID;
            var addPOP = db.tForumTitle.Where(p => p.fMC_ID == id).First().fFT_Popul;

            tForumTitle updatePopul = db.tForumTitle.Find(ftID);

            updatePopul.fFT_Popul       = updatePopul.fFT_Popul + 1;
            db.Entry(updatePopul).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();


            //讀取Detail
            ForumModel vm = new ForumModel();

            vm.Fclass = db.tForumClass.Where(p => p.fFC_Dad == null);

            vm.pushGood  = db.tPushGood;
            vm.Fmessage  = db.tForumMessage.Where(p => p.fMC_ID == id);
            vm.Ftitle    = db.tForumTitle.Where(p => p.fMC_ID == id);
            vm.employees = db.tEmployee.Where(p => p.tForumMessage.First().fMC_ID == id);

            return(View(vm));
        }
예제 #6
0
        public ActionResult Edit(ForumModel model, string type, string returnURL)
        {
            ForumModel item = FindItemById(model.ID, type);

            if (item == null)
            {
                return(RedirectToAction(CategoriesPage, Db.ForumCategories));
            }

            if (ModelState.IsValid)
            {
                item.Text = model.Text;

                try
                {
                    Db.Entry(item).State = EntityState.Modified;
                    Db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    var errorMessage = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                    ViewBag.ErrorMessage = string.Join("; ", errorMessage);
                    return(View(model));
                }

                return(Redirect(returnURL));
            }

            return(View(model));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            btnSearch.Text = DictionaryConstants.GoButtonText;
            txtSearch.Attributes.Add("placeholder", DictionaryConstants.Community_EnterConversation);

            if (!IsPostBack)
            {
                ResultCount = 10;
                Item currItem = Sitecore.Context.Item;
                if (currItem != null)
                {
                    hrfBack.HRef = LinkManager.GetItemUrl(currItem.Parent);
                    litBack.Text = currItem.Parent.Name;
                    ForumItem frmItem = new ForumItem(currItem);
                    Session["forumItem"] = frmItem;
                    if (frmItem != null)
                    {
                        ForumModel frmModel = Forum.ForumModelFactory(frmItem);

                        litForumName.Text = frmModel.Name;
                        if (frmModel != null)
                        {
                            Session["_threads"]  = frmModel.Threads;
                            rptThread.DataSource = frmModel.Threads.Take(ResultSet);
                            rptThread.DataBind();
                        }
                    }
                }
            }
        }
        //收回點讚
        public ActionResult recoveryGood(tPushGood recoveryPG, int?id = 1)
        {
            if (Request.Cookies["account"] == null)
            {
                return(RedirectToAction("Detail", "ForumHome", new { id = id }));
            }

            //傳值得ID便是文章編號,以及cookie的員工編號,便可找出他點讚的編號,刪掉就是取消
            string epid  = Request.Cookies["account"].Value;
            var    EP_ID = db.tEmployee.Where(p => p.fEp_Code == epid).Single().fEp_ID;

            var PGid = db.tPushGood.Where(p => p.fFM_ID == id && p.fEp_ID == EP_ID).Single().fPG_ID;

            tPushGood delePG = db.tPushGood.Find(PGid);

            db.tPushGood.Remove(delePG);
            db.SaveChanges();

            ForumModel vm = new ForumModel();

            vm.Fmessage = db.tForumMessage.Where(p => p.fFM_ID == id);
            vm.pushGood = db.tPushGood;

            return(PartialView(vm));
        }
        public ActionResult twitter_all(int?id = 1)
        {
            ForumModel vm = new ForumModel();

            vm.Fmessage = db.tForumMessage.Where(p => p.fFM_Dad == id);
            return(PartialView(vm));
        }
예제 #10
0
        public virtual IActionResult CreateForum(ForumModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageForums))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var forum = model.ToEntity <Forum>();
                forum.CreatedOnUtc = DateTime.UtcNow;
                forum.UpdatedOnUtc = DateTime.UtcNow;
                _forumService.InsertForum(forum);

                _notificationService.SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Forums.Forum.Added"));

                return(continueEditing ? RedirectToAction("EditForum", new { forum.Id }) : RedirectToAction("List"));
            }

            //prepare model
            model = _forumModelFactory.PrepareForumModel(model, null, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
        //點讚去
        public ActionResult pushGoodall(tPushGood updatePG, int?id = 1)
        {
            //當然你沒有帳號,會重登一次頁面,之後會要修改成登入頁面
            if (Request.Cookies["account"] == null)
            {
                return(RedirectToAction("Detail", "ForumHome", new { id = id }));
            }

            //傳值得ID便是文章編號,透過他可找出文章代碼,接著透過cookie找出會員編號,再匯入點讚裡面
            string epid  = Request.Cookies["account"].Value;
            var    EP_ID = db.tEmployee.Where(p => p.fEp_Code == epid).Single().fEp_ID;
            var    MC_ID = db.tForumMessage.Where(p => p.fFM_ID == id).Single().fMC_ID;

            updatePG.fEp_ID = EP_ID;
            updatePG.fFM_ID = id;

            db.tPushGood.Add(updatePG);
            db.SaveChanges();


            ForumModel vm = new ForumModel();

            vm.Fmessage = db.tForumMessage.Where(p => p.fFM_ID == id);
            vm.pushGood = db.tPushGood;

            return(PartialView(vm));
        }
예제 #12
0
        public virtual async Task<IActionResult> EditForum(ForumModel model, bool continueEditing)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageForums))
                return AccessDeniedView();

            //try to get a forum with the specified id
            var forum = await _forumService.GetForumByIdAsync(model.Id);
            if (forum == null)
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                forum = model.ToEntity(forum);
                forum.UpdatedOnUtc = DateTime.UtcNow;
                await _forumService.UpdateForumAsync(forum);

                _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.ContentManagement.Forums.Forum.Updated"));

                return continueEditing ? RedirectToAction("EditForum", forum.Id) : RedirectToAction("List");
            }

            //prepare model
            model = await _forumModelFactory.PrepareForumModelAsync(model, forum, true);

            //if we got this far, something failed, redisplay form
            return View(model);
        }
예제 #13
0
        public static ForumDTO Map(ForumModel forumModel)
        {
            ForumDTO result = MapperBag.ForumMapper.Map(forumModel);

            result.TopicDtos = MapperBag.TopicMapper.Map(forumModel.Topics).ToList();
            return(result);
        }
예제 #14
0
        public ForumModel GetBy(int id)
        {
            ForumModel post = new ForumModel();

            var sql = string.Format("SELECT * FROM PostTable WHERE PostId = '{0}'", id);
            var connectionString = "Server=(local);Database=Savnac.Database;Trusted_Connection=True;";

            var command = new SqlCommand(sql, new SqlConnection(connectionString));

            using (var connection = command.Connection)
            {
                connection.Open();

                using (var reader = command.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    post = new ForumModel()
                    {
                        postId     = (int)reader["postId"],
                        title      = reader["postTitle"].ToString(),
                        content    = reader["postContent"].ToString(),
                        datePosted = (DateTime)reader["postTime"],
                        courseId   = (int)reader["courseId"],
                        userName   = reader["userName"].ToString(),
                        isRead     = (bool)reader["post_isRead"]
                    };
                }
            }

            return(post);
        }
예제 #15
0
        public ActionResult CreateForum(ForumModel model, bool continueEditing)
        {
            if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageForums))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var utcNow = DateTime.UtcNow;
                var forum  = model.ToEntity();

                _forumService.InsertForum(forum);

                model.SeName = forum.ValidateSeName(model.SeName, forum.Name, true);
                _urlRecordService.SaveSlug(forum, model.SeName, 0);

                NotifySuccess(_services.Localization.GetResource("Admin.ContentManagement.Forums.Forum.Added"));

                return(continueEditing ? RedirectToAction("EditForum", new { forum.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            foreach (var forumGroup in _forumService.GetAllForumGroups(true))
            {
                var forumGroupModel = forumGroup.ToModel();
                model.ForumGroups.Add(forumGroupModel);
            }
            return(View(model));
        }
예제 #16
0
        public ActionResult CreateForum(ForumModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageForums))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var forum = model.ToEntity();
                forum.CreatedOnUtc = DateTime.UtcNow;
                forum.UpdatedOnUtc = DateTime.UtcNow;
                _forumService.InsertForum(forum);

                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Forums.Forum.Added"));
                return(continueEditing ? RedirectToAction("EditForum", new { forum.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            foreach (var forumGroup in _forumService.GetAllForumGroups())
            {
                var forumGroupModel = forumGroup.ToModel();
                model.ForumGroups.Add(forumGroupModel);
            }
            return(View(model));
        }
예제 #17
0
        public void update_a_forum()
        {
            //Create forum

            Connection one = new Connection();

            ForumRepo repo = new ForumRepo(new Connection());

            ForumModel forum = new ForumModel();

            forum.name        = "testname";
            forum.description = "testdescription";

            int id = repo.store(forum);

            forum.id = id;

            //Give forum a new name

            forum.name = "new name!";
            repo.update(forum);

            one.Connect();
            SqlCommand    sqlCommand = new SqlCommand("select * from forum where name = 'new name!'", one.getConnection());
            SqlDataReader reader     = sqlCommand.ExecuteReader();

            Assert.AreEqual(true, reader.HasRows);
            one.disConnect();

            repo.destroy(id);
        }
예제 #18
0
        public static Item CreateSitecoreForum(ForumModel frmModel, string groupItemID, Language lang)
        {
            Item grpItem = Groups.ConvertGroupIDtoSitecoreItem(groupItemID);
            return CreateSitecoreForum(frmModel, grpItem, lang);


        }
예제 #19
0
        public IActionResult EditForum(ForumModel model, bool continueEditing)
        {
            var forum = _forumService.GetForumById(model.Id);

            if (forum == null)
            {
                //No forum found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                forum = model.ToEntity(forum);
                forum.UpdatedOnUtc = DateTime.UtcNow;
                _forumService.UpdateForum(forum);

                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.Forums.Forum.Updated"));
                return(continueEditing ? RedirectToAction("EditForum", new { id = forum.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            foreach (var forumGroup in _forumService.GetAllForumGroups())
            {
                var forumGroupModel = forumGroup.ToModel();
                model.ForumGroups.Add(forumGroupModel);
            }
            return(View(model));
        }
        public ActionResult EditForum(ForumModel model, bool continueEditing)
        {
            var forum = _forumService.GetForumById(model.Id);

            if (forum == null)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                forum = model.ToEntity(forum);

                _forumService.UpdateForum(forum);

                model.SeName = forum.ValidateSeName(model.SeName, forum.Name, true);
                _urlRecordService.SaveSlug(forum, model.SeName, 0);

                UpdateLocales(model, forum);

                NotifySuccess(_services.Localization.GetResource("Admin.ContentManagement.Forums.Forum.Updated"));

                return(continueEditing ? RedirectToAction("EditForum", forum.Id) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            foreach (var forumGroup in _forumService.GetAllForumGroups(0, true))
            {
                var forumGroupModel = forumGroup.ToModel();
                model.ForumGroups.Add(forumGroupModel);
            }
            return(View(model));
        }
        public ActionResult twitter_short(int?id = 1)
        {
            ForumModel vm = new ForumModel();

            vm.Fmessage = db.tForumMessage.Where(p => p.fFM_Dad == id).OrderByDescending(p => p.fFM_Date);
            return(PartialView(vm));
        }
예제 #22
0
 public IActionResult Post(ForumModel model)//pass in QuizModel as a quizmodel then instantiate it and add it.
 {
     repo.AddPost(model);
     return(Redirect("Forum"));
     //  return View(model);
     //repo.AddPost(model)^
 }
        public ActionResult Index()
        {
            ForumModel       forumModel = new ForumModel();
            DataTable        posts      = new DataTable();
            List <PostModel> PostModel  = new List <PostModel>();


            using (SqlConnection sqlCon = new SqlConnection(connectionString))
            {
                sqlCon.Open();

                string         getPosts = "SELECT * FROM Tbl_Posts ORDER BY Tbl_Posts.PostId DESC";
                SqlDataAdapter sqlDa    = new SqlDataAdapter(getPosts, sqlCon);
                sqlDa.Fill(posts);


                for (int i = 0; i < posts.Rows.Count; i++)
                {
                    PostModel.Add(new Models.PostModel
                    {
                        PostId      = int.Parse(posts.Rows[i]["PostId"].ToString()),
                        PostContent = posts.Rows[i]["PostContent"].ToString(),
                        PostFile    = posts.Rows[i]["PostFile"].ToString(),
                        Date        = posts.Rows[i]["Date"].ToString(),
                    });
                }

                forumModel.PostModels = PostModel;
            }
            return(View(forumModel));
        }
예제 #24
0
        public ActionResult ComposePost(ForumModel model)
        {
            ForumRepository repository = new ForumRepository();

            repository.AddPost(User.Identity.Name, model.title, model.content, model.courseId);

            return(RedirectToAction("PostMessage"));
        }
        // GET: Home
        //討論版首頁,可以看到熱門文章與入口
        public ActionResult FirstPage(int?id = 0)
        {
            ForumModel vm = new ForumModel();

            vm.Fclass = db.tForumClass.Where(p => p.fFC_Dad == null);

            return(View(vm));
        }
 public IActionResult Reply(ForumModel forumModel)
 {
     forumModel.userIdReply = HttpContext.Session.GetInt32("UserId") ?? 0;
     forumModel.date        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     forumModel.SaveReply();
     forumModel.answer = String.Empty;
     return(RedirectToAction("Index", "Forum"));
 }
예제 #27
0
        public IActionResult AddForum(int GameID)
        {
            ForumModel forum = new ForumModel();

            forum.GameID = GameID;

            return(View(forum));
        }
예제 #28
0
        public ActionResult ReadPost(ForumModel model)
        {
            ForumRepository repository = new ForumRepository();

            repository.MarkRead(model.postId);

            return(View(model));
        }
예제 #29
0
        public async Task UpdateForum(ForumModel forum)
        {
            forum.UpdateTimestamps(false);

            using (var ct = GetConnection(DatabaseType.Forum, false))
            {
                await ct.DbConnection.ExecuteAsync(ReadQuery("UpdateForum", ct.ProviderName), forum, transaction : ct.DbTransaction);
            }
        }
        public ActionResult FPclicktitle(int?id = 0)
        {
            ForumModel vm = new ForumModel();

            vm.Fclass = db.tForumClass;
            vm.Ftitle = db.tForumTitle.AsEnumerable().Where(a => a.fFT_Date > DateTime.Now.AddMonths(-3)).OrderByDescending(a => a.tMessageCode.tForumMessage.First().tPushGood.Count()).Take(5);

            return(PartialView(vm));
        }
        public ActionResult FPpushgood(int?id = 0)
        {
            ForumModel vm = new ForumModel();

            vm.Fclass = db.tForumClass;
            vm.Ftitle = db.tForumTitle.AsEnumerable().Where(a => a.fFT_Date > DateTime.Now.AddMonths(-3)).OrderByDescending(a => a.fFT_Popul).Take(5);

            return(PartialView(vm));
        }
예제 #32
0
 public static ForumModel ForumModelFactory(ForumItem item)
 {
     ForumModel frm = new ForumModel(item, TelligentService.TelligentService.ReadThreadList);
     return frm;
 }
예제 #33
0
        public static Item CreateSitecoreForum(ForumModel frmModel, GroupItem grpItem, Language lang)
        {

            Item newItem = null;
            try
            {
                if (frmModel != null && grpItem != null && lang != null)
                {
                    //Again we need to handle security
                    //In this example we just disable it
                    using (new SecurityDisabler())
                    {
                        //First get the parent item from the master database
                        Database masterDb = global:: Sitecore.Configuration.Factory.GetDatabase("master");
                        Item parentItem = masterDb.Items[grpItem.InnerItem.Paths.Path, lang];


                        //Now we need to get the template from which the item is created (Forum Thread Template)
                        TemplateItem template = masterDb.GetTemplate(ForumModel.TemplateID);

                        //StringBuilder sb = new StringBuilder(ItemName.Trim());

                        // string newName = ItemName.Replace('.', '_');//.Substring(0, ItemName.LastIndexOf("."));
                        // if(newName.Contains("."))
                        //     newName=newName.Substring(newName.IndexOf(".") + 1);

                        newItem = masterDb.GetItem(parentItem.Paths.Path + "/" + frmModel.Name, lang);
                        if (newItem == null)
                        {
                            //Now we can add the new item as a child to the parent
                            newItem = parentItem.Add(frmModel.Name, template);
                        }


                        //We can now manipulate the fields and publish as in the previous example
                        //Item item = masterDb.GetItem(newItem);
                        //Begin editing
                        newItem.Editing.BeginEdit();
                        try
                        {
                            //perform the editing
                            newItem.Fields["GroupID"].Value = frmModel.GroupID;
                            newItem.Fields["ForumID"].Value = frmModel.ForumID;
                            
                            // errorState = true;
                        }
                        catch (Exception ex)
                        {
                            // errorState = false;
                            throw ex;
                        }
                        finally
                        {
                            //Close the editing state
                            newItem.Editing.EndEdit();
                          
                        }



                    }
                }
            }
            catch (Exception ex)
            {
                //Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Error with :" + ItemName + " (" + lang.Name + ")\n Details:\n" + ex.Message));
                Sitecore.Diagnostics.Error.LogError("Error with :" + frmModel.Name + " (" + lang.Name + ")\n Details:\n" + ex.Message);
                newItem = null;
            }

            return newItem;
        }