예제 #1
0
        protected void BT_AddForum_Click(object sender, EventArgs e)
        {
            ForumService  service = new ForumService();
            NewForumModel model   = new NewForumModel()
            {
                CreationTime = DateTime.Now, ForumDsp = TB_Desription.Text.Trim(), ForumName = TB_Name.Text.Trim(), ModifiedTime = DateTime.Now, ThreadCount = 0
            };

            service.CreateForum(model);
            Response.Redirect("ForumList.aspx");
        }
예제 #2
0
        /// <summary>
        /// 创建贴吧
        /// </summary>
        /// <param name="model"></param>
        public void CreateForum(NewForumModel model)
        {
            IRepository <Forum> forumRep = Factory.Factory <IRepository <Forum> > .GetConcrete <Forum>();

            //IForumsRepository forumRep = FBS.Factory.Factory<IForumsRepository>.GetConcrete();

            Forum fo = new Forum(model.ForumName, model.ForumDsp, model.Priority);

            forumRep.Add(fo);
            forumRep.PersistAll();
        }
예제 #3
0
        /// <summary>
        /// Gets user input into a model for making a new Forum.
        /// </summary>
        /// <param name="model">NewForumModel obj.; what is needed at least to make a new one.</param>
        /// <returns>Object: a new ForumEntity based on the NewForumModel data template.</returns>
        private ForumEntity BuildForum(NewForumModel model)
        {
            var board = _boardEntityService.GetById(model.BoardId);

            return(new ForumEntity
            {
                Title = model.Title,
                Description = model.Description,
                CreatedAt = DateTime.Now,
                //ImageUrl = imgageUri, // Placeholder; not added; seems silly to have a forum or thread have an picture like a user would have a profile image.
                Board = board
            });
        }
예제 #4
0
        public IActionResult Create(int id)
        {
            // TODO: somehow link the forum to be created to a Board by user selection.
            //var board = _boardEntityService.GetById(id);

            //var model = new NewForumModel
            //{
            //	BoardId = board.Id,
            //	BoardName = board.Title
            //};

            var model = new NewForumModel {
            };

            return(View(model));
        }
예제 #5
0
        public async Task <IActionResult> AddForum(NewForumModel model)
        {
            var imageUri = "images/users/default.png";

            // This will never be used; never adding cloud storage functions; it is just a demo app.
            if (model.ImageUpload != null)
            {
                // Set the Forum's Image to the URI
                var blockBlob = UploadForumImage(model.ImageUpload);
                imageUri = blockBlob.Uri.AbsoluteUri;
            }

            var forum = BuildForum(model);

            //_forumEntityService.Create(forum).Wait();
            await _forumEntityService.Create(forum);

            return(RedirectToAction("Index", "Forum", new { id = forum.Id }));
        }
예제 #6
0
        public async Task <IActionResult> AddNewForum(NewForumModel model)
        {
            var ImageUri = "default.png";

            if (model.ImageUpload != null)
            {
                ImageUri = GetImageUri(model.ImageUpload);
            }
            var forum = new Forum
            {
                Title       = model.Title,
                Description = model.Description,
                Created     = DateTime.Now,
                ImageUrl    = "/images/" + ImageUri
            };
            await _forumService.Create(forum);

            return(RedirectToAction("Index", "Forum"));
        }
예제 #7
0
        public IActionResult Create()
        {
            var model = new NewForumModel();

            return(View(model));
        }