public async Task <IActionResult> CreateTopicGroup(ForumIndexViewModel model) { model.TopicGroups = topicGroupsRepository.FindAll(); if (string.IsNullOrWhiteSpace(model.NewTopicGroup.Title)) { ModelState.AddModelError <ForumIndexViewModel>(m => m.NewTopicGroup.Title, "Zadejte název skupiny témat."); return(View("Index", model)); } try { model.NewTopicGroup.Created = DateTime.Now; model.NewTopicGroup.User = await userManager.GetUserAsync(User); await topicGroupsRepository.CreateAsync(model.NewTopicGroup); } catch (Exception) { ModelState.AddModelError <ForumIndexViewModel>(m => m.NewTopicGroup.Title, "Skupina s tímto názvem již existuje"); return(View("Index", model)); } return(RedirectToAction("Index")); }
public IActionResult IndexWithId(int messageId) { var viewModel = new ForumIndexViewModel(); viewModel.Messages = forumLogic.GetAllMessages(); return(Redirect($"{Url.Action("Index", new { ForumIndexViewModel = viewModel })}#" + messageId)); }
public IActionResult Index(int id = 1) { var forums = this.forumsService .GetAll <ForumViewModel>(ForumsPerPage, (id - 1) * ForumsPerPage); var viewModel = new ForumIndexViewModel { Forums = forums }; var count = this.forumsService.GetCount(); var pagination = new PaginationViewModel(); pagination.PagesCount = (int)Math.Ceiling((double)count / ForumsPerPage); if (pagination.PagesCount == 0) { pagination.PagesCount = 1; } pagination.CurrentPage = id; viewModel.Pagination = pagination; return(this.View(viewModel)); }
public IActionResult Index() { var forums = this.forumsService.GetAll() .Select(forum => new ForumListingViewModel { Id = forum.Id, Description = forum.Description, Title = forum.Title, NumberOfPosts = forum.Posts?.Count() ?? 0, Latest = this.GetLatestPost(forum.Id) ?? new PostListingViewModel(), NumberOfUsers = this.forumsService.GetActiveUsers(forum.Id).Count(), ImageUrl = forum.ImageUrl, HasRecentPost = this.forumsService.HasRecentPost(forum.Id), }); var forumListingModels = forums as IList <ForumListingViewModel> ?? forums.ToList(); var model = new ForumIndexViewModel { ForumList = forumListingModels.OrderBy(forum => forum.Title), NumberOfForums = forumListingModels.Count, }; return(this.View(model)); }
public IActionResult Index() { ForumIndexViewModel model = new ForumIndexViewModel(); model.ForumCategories = forumCategoryCollection.GetForumCategories(); return(View(model)); }
public IActionResult Index() { var viewModel = new ForumIndexViewModel(); viewModel.Messages = forumLogic.GetAllMessages(); return(View(viewModel)); }
public IActionResult DeleteReply(ForumIndexViewModel viewModel) { var userId = Convert.ToInt32(Convert.ToString(User.Claims.Where(claim => claim.Type == "Id").Select(claim => claim.Value).SingleOrDefault())); var replyId = viewModel.ReplyId; forumLogic.DeleteReply(replyId, userId); return(RedirectToAction("Index")); }
public IActionResult AddMessage(ForumIndexViewModel viewModel) { var userId = Convert.ToInt32(Convert.ToString(User.Claims.Where(claim => claim.Type == "Id").Select(claim => claim.Value).SingleOrDefault())); var message = viewModel.Message; message.UserId = userId; var messageId = forumLogic.AddMessage(message); return(RedirectToAction("IndexWithId", new{ messageId = messageId })); }
public ActionResult Index(int?page) { var db = new ApplicationDbContext(); var groups = db.Groups.OrderBy(u => u.GroupName).ToList(); var currentPage = page ?? 1; var model = new ForumIndexViewModel { Groups = groups.ToPagedList(currentPage, DefaultPageSize) }; return(View(model)); }
public IActionResult Index() { var forums = _forumService.GetAll() .Select(f => new ForumListViewModel { Id = f.Id, Description = f.Description, Title = f.Title }); var vm = new ForumIndexViewModel { ForumList = forums }; return(View(vm)); }
public async Task <IActionResult> CreateTopic(ForumIndexViewModel model) { model.TopicGroups = topicGroupsRepository.FindAll(); if (string.IsNullOrWhiteSpace(model.NewTopic.Title)) { ModelState.AddModelError <ForumIndexViewModel>(m => m.NewTopic.Title, "Zadejte název tématu."); return(View("Index", model)); } if (string.IsNullOrWhiteSpace(model.NewTopic.Info)) { ModelState.AddModelError <ForumIndexViewModel>(m => m.NewTopic.Info, "Zadejte informace o novém tématu."); return(View("Index", model)); } if (string.IsNullOrWhiteSpace(model.SelectedTopicGroup)) { ModelState.AddModelError <ForumIndexViewModel>(m => m.SelectedTopicGroup, "Vyberte skupinu témat."); return(View("Index", model)); } int id = Convert.ToInt32(model.SelectedTopicGroup); var topicGroup = await topicGroupsRepository.FindByIdAsync(id); if (topicGroup == null) { Console.WriteLine("GroupNull"); TempData.AddErrorMessage("Do této skupiny nemůžete přidat nové téma."); return(View("Index", model)); } if (topicGroup.Topics.Any(t => t.Title.Trim() == model.NewTopic.Title.Trim())) { ModelState.AddModelError <ForumIndexViewModel>(m => m.NewTopic.Title, "Téma s tímto názvem již v této skupině existuje."); return(View("Index", model)); } Console.WriteLine("Creating"); model.NewTopic.Created = DateTime.Now; model.NewTopic.User = await userManager.GetUserAsync(User); model.NewTopic.TopicGroup = topicGroup; await topicsRepository.CreateAsync(model.NewTopic); return(RedirectToAction("Index")); }
public IActionResult Index() { var forums = _forum.GetAll() .Select(forum => new ForumViewModel { Id = forum.Id, Name = forum.Title, Description = forum.Description }); var model = new ForumIndexViewModel { ForumView = forums }; return(View(model)); }
public IActionResult Index() { IEnumerable <ForumListingViewModel> forums = _forumService.GetAll() .Select(forum => new ForumListingViewModel { Id = forum.Id, Title = forum.Title, Description = forum.Description }); var model = new ForumIndexViewModel { ForumList = forums }; return(View(model)); }
public async Task <IActionResult> Index(string id, int page) { if (String.IsNullOrEmpty(id)) { id = "Root"; } ForumIndexViewModel model = new ForumIndexViewModel() { Category = id, userManager = _userManager, amount = 10, page = page }; return(View(model)); }
public ActionResult Index() { var forums = _forumService.GetAll() .Select(f => new ForumListingViewModel { Id = f.Id, Name = f.Title, Description = f.Description }); var model = new ForumIndexViewModel { ForumList = forums }; return(View(model)); }
/*public ForumController() * { * this._forumRepositories = _forumRepositories; * }*/ // GET: Forum public ActionResult Index() { var forums = _forumRepositories.GetAll().Select(forum => new ForumListingModel { Id = forum.Id, Name = forum.Title, Description = forum.Description, Created = forum.Created.ToString(), postsCount = forum.Posts.Count, ActiveUsers = _forumRepositories.GetAllActiveUsers(forum.Id).Count() }); var model = new ForumIndexViewModel { ForumList = forums }; return(View(model)); }
public ForumIndexViewModel GetAllForums() { var forums = _forumService.GetAll() .Select(forum => new ForumListViewModel { Id = forum.Id, Title = forum.Title, Description = forum.Description, ImageUrl = forum.ImageUrl, AmountTotalPost = forum.AmountTotalPost, AmountTotalUser = forum.AmountTotalUser }); var model = new ForumIndexViewModel { ForumList = forums }; return(model); }
public IActionResult Index() { var forums = _forumService.GetAll().Select(forum => new ForumListingViewModel { Id = forum.Id, Name = forum.Title, Description = forum.Description, NumberOfPosts = forum.Posts?.Count() ?? 0, NumberOfUsers = _forumService.GetAllActiveUsers(forum.Id).Count(), ImageUrl = forum.ImageUrl, HasRecentPost = _forumService.HasRecentPost(forum.Id) }); var model = new ForumIndexViewModel { ForumList = forums.OrderBy(f => f.Name) }; return(View(model)); }
public void Include(ForumIndexViewModel vm) { var vm1 = new ForumIndexViewModel(); }
protected override void Init(Bundle savedInstanceState) { ViewModel = ViewModelLocator.ForumsIndex; ViewModel.Init(); }
public ForumIndexItem(Context context, ForumIndexViewModel parentViewModel) : base(context) { _parentViewModel = parentViewModel; }