示例#1
0
        /// <summary>
        /// Threads to thread edit model.
        /// </summary>
        /// <param name="thread">The thread.</param>
        /// <param name="categoryList">The category list.</param>
        /// <param name="isNew">if set to <c>true</c> [is new].</param>
        /// <returns>a ThreadEditModel</returns>
        public static ThreadEditModel ThreadToThreadEditModel(Thread thread, Dictionary<int, string> categoryList, bool isNew)
        {
            ThreadEditModel viewModel = new ThreadEditModel
            {
                ThreadId = thread.ThreadId,
                CategoryId = thread.CategoryId,
                Username = thread.Username,
                Subject = thread.Subject,
                Categories = categoryList,
                New = isNew
            };

            return viewModel;
        }
示例#2
0
 /// <summary>
 /// Froms the thread edit model.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns>New Thread from ThreadEditModel</returns>
 public static Thread ThreadEditModeltToThread(ThreadEditModel model)
 {
     Thread thread = new Thread
     {
         Modified = DateTime.Now,
         Subject = model.Subject,
         Username = model.Username,
         CategoryId = model.CategoryId,
         ThreadId = model.ThreadId
     };
     return thread;
 }
示例#3
0
        /// <summary>
        /// Toes the thread edit model.
        /// </summary>
        /// <returns>a ThreadEditModel</returns>
        public static ThreadEditModel ThreadToThreadEditModel(Thread thread)
        {
            ThreadEditModel viewModel = new ThreadEditModel
            {
                ThreadId = thread.ThreadId,
                CategoryId = thread.CategoryId,
                Username = thread.Username,
                Subject = thread.Subject
            };

            return viewModel;
        }
示例#4
0
        public async Task<ActionResult> CreateThread(int categoryId)
        {
            await this.UpdateCategoryListAsync();
            var threadViewModel = new ThreadEditModel
            {
                New = true,
                CategoryId = categoryId,
                Categories = this.CategoryList
            };

            if (categoryId != 0)
            {
                return View("EditThread", threadViewModel);
            }
            return RedirectToActionPermanent("Index");
        }