public async Task <IActionResult> Topic(int id, int?page) { // Pagination int pageSize = 20; TopicViewModel vm = new TopicViewModel() { Topic = await _topicRepository.GetById(id), Posts = await _topicRepository.GetByIdWithPosts(id, page ?? 1, pageSize) }; // Manually set breadcrumb nodes var childNode1 = new MvcBreadcrumbNode("Forum", "Home", vm.Topic.Forum.Title) { RouteValues = new { id = vm.Topic.Forum.Id } }; var childNode2 = new MvcBreadcrumbNode("Topic", "Home", "ViewData.Title") { OverwriteTitleOnExactMatch = true, Parent = childNode1 }; ViewData["BreadcrumbNode"] = childNode2; return(View(vm)); }
public async Task <IActionResult> Index(string organizationName, string repositoryName, [FromQuery] Dictionary <string, List <string> > filters = null) { var model = new BrowseRepositoryViewModel() { RepositoryName = repositoryName, OrganizationName = organizationName }; this.telemetryClient.TrackViewRepository(organizationName, repositoryName); var queryParam = new RepositoryQueryParameter(organizationName, repositoryName); var repositoryInfo = (await this.repositoryService.GetRepositories(queryParam)).FirstOrDefault(); if (repositoryInfo == null) { this.TempData["Error"] = $"Did not find a repository [{repositoryName}] on [{organizationName}]."; return(this.RedirectToAction("PageNotFound", "Home")); } var projectsTask = this.repositoryService.GetAllCurrentProjects(repositoryInfo); var stampsTask = this.repositoryService.GetStamps(repositoryInfo); var downloadStatsTask = this.statisticsService.GetDownloadStatistics(repositoryInfo); await Task.WhenAll(projectsTask, stampsTask, downloadStatsTask).ConfigureAwait(false); ManifestQueryResult result = projectsTask.Result; model.NumberOfStamps = stampsTask.Result.Count; model.RepositoryMode = result.Projects?.FirstOrDefault()?.RepositoryInfo?.RepositoryMode.ToString(); List <ProjectInfoViewModel> manifests = this.mapper.Map <List <ProjectInfoViewModel> >(result.Projects); if (manifests.Any()) { model.RepositoryStamp = StampSorter.GetNewestStamp(manifests.Select(x => x.RepositoryStamp).ToList()); var orderedTimes = manifests.OrderByDescending(x => x.AddedDateTime).ToList(); model.ImportedDate = orderedTimes.First().AddedDateTime; model.ImportDuration = model.ImportedDate - orderedTimes.Last().AddedDateTime; model.NumberOfProjects = manifests.Count; model.NumberOfAutogeneratedProjects = manifests.Count(x => x.Autogenerated); model.AutogeneratedPercentage = Math.Round((decimal)model.NumberOfAutogeneratedProjects / model.NumberOfProjects * 100, 1); model.NumberOfComponents = manifests.Sum(x => x.Components.Count); model.NumberOfTags = manifests.Sum(prj => prj.Components.Sum(cmp => cmp.Tags.Count)); foreach (ProjectInfoViewModel projectInfoViewModel in manifests) { projectInfoViewModel.DownloadsCount = downloadStatsTask.Result.ProjectDownloadData.FirstOrDefault(x => x.ProjectKey == projectInfoViewModel.ProjectUri)?.DownloadCount ?? 0; } } ProjectsTableModel projectsTableModel = new ProjectsTableModel(manifests, false, false); model.ProjectsTable = projectsTableModel; model.ProjectsTable.Filters = filters; model.SearchIndexViewModel = this.GetRepositoriesSelectList(organizationName, repositoryName); MvcBreadcrumbNode breadcrumb = PrepareIndexBreadcrumb(organizationName, repositoryName); this.ViewData["BreadcrumbNode"] = breadcrumb; return(this.View(model)); }
public async Task <IActionResult> Reply(int id) { ReplyViewModel vm = new ReplyViewModel() { Topic = await _topicRepository.GetById(id) }; // Manually set breadcrumb nodes var childNode1 = new MvcBreadcrumbNode("Forum", "Home", vm.Topic.Forum.Title) { RouteValues = new { id = vm.Topic.Forum.Id } }; var childNode2 = new MvcBreadcrumbNode("Topic", "Home", vm.Topic.Title) { RouteValues = new { id = vm.Topic.Id }, OverwriteTitleOnExactMatch = true, Parent = childNode1 }; var childNode3 = new MvcBreadcrumbNode("Reply", "Home", "Reply") { RouteValues = new { id = vm.Topic.Id }, OverwriteTitleOnExactMatch = true, Parent = childNode2 }; ViewData["BreadcrumbNode"] = childNode3; return(View(vm)); }
public async Task <IActionResult> EditPost(int id) { Post post = await _postRepository.GetById(id); EditPostViewModel vm = new EditPostViewModel() { Post = await _postRepository.GetById(id), Contents = post.Contents }; // Manually set breadcrumb nodes var childNode1 = new MvcBreadcrumbNode("Forum", "Home", vm.Post.Topic.Forum.Title) { RouteValues = new { id = vm.Post.Topic.Forum.Id } }; var childNode2 = new MvcBreadcrumbNode("Topic", "Home", vm.Post.Topic.Title) { RouteValues = new { id = vm.Post.Topic.Id }, OverwriteTitleOnExactMatch = true, Parent = childNode1 }; var childNode3 = new MvcBreadcrumbNode("Editing post", "Home", "Editing post") { Parent = childNode2 }; ViewData["BreadcrumbNode"] = childNode3; return(View(vm)); }
public ActionResult Edit(int taskId) { ViewBag.User = unitOfWork.Tasks.GetLoggedInUser(); TaskModel taskToEdit = unitOfWork.Tasks.GetTask(taskId); if (taskToEdit == null) { return(RedirectToAction("Projects")); } else { int projectId = taskToEdit.ProjectID; string projectName = tasksRepository.GetProject(projectId).ProjectName; var projectNode = new MvcBreadcrumbNode("Tasks", "Home", projectName) { RouteValues = new { projectId, listType = taskToEdit.ListType } }; var taskNode = new MvcBreadcrumbNode("Edit", "Home", taskToEdit.Name) { RouteValues = new { taskId }, Parent = projectNode }; ViewData["BreadcrumbNode"] = taskNode; return(View()); } }
public ViewResult CreateSubTask(int taskId) { ViewBag.User = unitOfWork.Tasks.GetLoggedInUser(); ViewBag.Action = "Create New Sub Task"; var parentTask = tasksRepository.GetTask(taskId); string projectName = tasksRepository.GetProject(parentTask.ProjectID).ProjectName; var projectNode = new MvcBreadcrumbNode("Tasks", "Home", projectName) { RouteValues = new { projectId = parentTask.ProjectID, listType = parentTask.ListType } }; var taskNode = new MvcBreadcrumbNode("Edit", "Home", parentTask.Name) { RouteValues = new { taskId }, Parent = projectNode }; var subTaskNode = new MvcBreadcrumbNode("EditSubTask", "Home", "New Task") { Parent = taskNode }; ViewData["BreadcrumbNode"] = subTaskNode; return(View("EditSubTask", new SubTask() { TaskModelTaskID = parentTask.TaskID })); }
public IActionResult Register() { var loginNode = new MvcBreadcrumbNode("Register", "Login", "Tạo tài khoản mới"); ViewData["BreadcrumbNode"] = loginNode; return(View()); }
public async Task <IActionResult> Details(int id) { var httpClient = await _facilityManagementHttpClient.GetClient(); var response = await httpClient.GetAsync($"api/inventory/{id}").ConfigureAwait(false); if (response.IsSuccessStatusCode) { var responseAsString = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var detailsViewModel = JsonConvert.DeserializeObject <DetailsViewModel>(responseAsString); var childNode1 = new MvcBreadcrumbNode("Index", "InventoryObjects", "Inventory"); var childNode2 = new MvcBreadcrumbNode("Index", "InventoryObjectsController", detailsViewModel.Name) { Parent = childNode1 }; ViewData["BreadcrumbNode"] = childNode2; return(View(detailsViewModel)); } else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { return(RedirectToAction("AccessDenied", "Authorization")); } throw new Exception($"A problem happened while calling the API: {response.ReasonPhrase}"); }
public IActionResult Login() { if (UserStatus.getUserStatus(this, "Client")) { return(RedirectToAction("Index", "Home", new { message = "Đăng nhập rồi bạn ie" })); } var loginNode = new MvcBreadcrumbNode("Login", "Login", "Đăng nhập"); ViewData["BreadcrumbNode"] = loginNode; return(View()); }
public ViewResult View(int suggestionId) { var suggestion = unitOfWork.Suggestions.Get(suggestionId); var feedbackHomeNode = new MvcBreadcrumbNode("Index", "Developer", "Feedback"); var feedbackViewNode = new MvcBreadcrumbNode("View", "Developer", suggestion.User + " - " + suggestion.PostDate) { Parent = feedbackHomeNode }; ViewData["BreadcrumbNode"] = feedbackViewNode; return(View(suggestion)); }
public IActionResult Danhmucs(int dmID) { var dm = db.Danhmuc.FirstOrDefault(n => n.IddanhMuc == dmID); if (dm != null) { List <Sanpham> spLst = db.Sanpham.Where(n => n.DanhMuc == dmID).ToList(); var categoryNode = new MvcBreadcrumbNode("DanhMucs", "Home", dm.TenDm.ToUpper()); ViewData["BreadcrumbNode"] = categoryNode; return(View(spLst)); } return(RedirectToAction("Error")); }
public ViewResult Create(int projectId, string fromAction) { string projectName = tasksRepository.GetProject(projectId).ProjectName; var projectNode = new MvcBreadcrumbNode("Tasks", "Home", projectName) { RouteValues = new { projectId, listType = fromAction } }; var taskNode = new MvcBreadcrumbNode("Create", "Home", "New Task") { Parent = projectNode }; ViewData["BreadcrumbNode"] = taskNode; return(View("Edit")); }
private static MvcBreadcrumbNode PrepareIndexBreadcrumb(string organizationName, string repositoryName) { var breadCrumb = new MvcBreadcrumbNode(nameof(RepositoryController.Index), "Repository", organizationName, areaName: "Catalog") { RouteValues = new { organizationName = organizationName, repositoryName = repositoryName } }; var breadCrumb2 = new MvcBreadcrumbNode(nameof(RepositoryController.Index), "Repository", repositoryName) { RouteValues = new { organizationName = organizationName, repositoryName = repositoryName }, Parent = breadCrumb }; var breadCrumb3 = new MvcBreadcrumbNode(nameof(RepositoryController.Index), "Repository", "Repository overview") { Parent = breadCrumb2 }; return(breadCrumb3); }
public IActionResult Chitiets(int idsp) { var sanpham = db.Sanpham.Include(dm => dm.DanhMucNavigation).FirstOrDefault(n => n.IdsanPham == idsp); if (sanpham != null) { // Manually create the nodes (assuming you used the attribute to create a Default node, otherwise create it manually too). var categoryNode = new MvcBreadcrumbNode("DanhMucs", "Home", sanpham.DanhMucNavigation.TenDm.ToUpper()) { RouteValues = new { dmID = sanpham.DanhMuc.Value } }; // When manually creating nodes, you have the option to use route values in case you need them. var productNode = new MvcBreadcrumbNode("Chitiets", "Home", sanpham.TenSp) { Parent = categoryNode }; //List<Sanpham> spLst = db.Sanpham.Where(n => n.IdsanPham == idsp).ToList(); ViewData["BreadcrumbNode"] = productNode; return(View(sanpham)); } return(RedirectToAction("Error")); }
public async Task <IActionResult> CreateTopic(int id) { CreateTopicViewModel vm = new CreateTopicViewModel() { Forum = await _forumRepository.GetById(id) }; // Manually set breadcrumb nodes var childNode1 = new MvcBreadcrumbNode("Forum", "Home", vm.Forum.Title) { RouteValues = new { id = vm.Forum.Id } }; var childNode2 = new MvcBreadcrumbNode("CreateTopic", "Home", "Creating topic") { RouteValues = new { id = vm.Forum.Id }, OverwriteTitleOnExactMatch = true, Parent = childNode1 }; ViewData["BreadcrumbNode"] = childNode2; return(View(vm)); }