public async Task <IActionResult> AssignmentsInCourses(AssignmentFilterModel filters = null) { var user = await this.userManager.GetUserAsync(this.User); var educatorId = this.educatorService.GetByUserId(user.Id).Id; //Should not be possible but ... if (educatorId == null) { return(View("../AccessDenied")); } var educatorCoursesIds = this.courseService.GetAllByEducator(educatorId).Select(c => c.Id); var assignments = new List <AssignmentListViewModel>(); foreach (var courseId in educatorCoursesIds) { var courseAssignments = this.assignmentService.GetByCourseId(courseId); if (courseAssignments != null && courseAssignments.Count() > 0) { assignments.AddRange(courseAssignments); } } var filteredAssignments = ApplyAssignmentFilters(filters, assignments); filteredAssignments = filteredAssignments.OrderByDescending(a => a.DateCreated).ToList(); return(View(filteredAssignments)); }
public ActionResult AssignmentsFilter(AssignmentFilterModel model) { if (model.PageChanged == 0) { model.Page = 1; } else { model.PageChanged = 0; } return(RedirectToAction("Assignments", model)); }
public void AssignmentFilter_ByStatusExecuted() { var filter = new AssignmentFilterModel { Status = AssignmentStatus.Executed }; var list = filter.Apply(mockRequests.AsQueryable(), _clock); var actual = mockRequests.Where(r => r.Order.Status == OrderStatus.Delivered); list.Should().HaveCount(actual.Count()); list.Should().Contain(actual); }
public void AssignmentFilter_ByRegion() { var region = Region.Regions.Where(r => r.Name == "Gotland").Single(); var filter = new AssignmentFilterModel { RegionId = region.RegionId }; var list = filter.Apply(mockRequests.AsQueryable(), _clock); var actual = mockRequests.Where(r => r.Order.Region == region); list.Should().HaveCount(actual.Count()); list.Should().Contain(actual); }
public void AssignmentFilter_ByOrderNumber() { var orderNum = "654"; var filter = new AssignmentFilterModel { OrderNumber = orderNum }; var list = filter.Apply(mockRequests.AsQueryable(), _clock); var actual = mockRequests.Where(req => req.Order.OrderNumber.Contains(orderNum)); list.Should().HaveCount(actual.Count()); list.Should().Contain(actual); }
public void AssignmentFilter_ByLanguage() { var language = mockLanguages.Where(l => l.Name == "Chinese").Single(); var filter = new AssignmentFilterModel { LanguageId = language.LanguageId }; var list = filter.Apply(mockRequests.AsQueryable(), _clock); var actual = mockRequests.Where(r => r.Order.LanguageId == language.LanguageId); list.Should().HaveCount(actual.Count()); list.Should().Contain(actual); }
public void AssignmentFilter_ByCustomer() { int customerId = 1; var filter = new AssignmentFilterModel { CustomerOrganizationId = customerId }; var list = filter.Apply(mockRequests.AsQueryable(), _clock); var actual = mockRequests.Where(r => r.Order.CustomerOrganisationId == customerId); list.Should().HaveCount(actual.Count()); list.Should().Contain(actual); }
public void AssignmentFilter_ByDateRange() { var filter = new AssignmentFilterModel { DateRange = new DateRange { Start = new DateTime(2018, 07, 01), End = new DateTime(2018, 09, 30) } }; var list = filter.Apply(mockRequests.AsQueryable(), _clock); var actual = new[] { mockRequests[2], mockRequests[3], mockRequests[4], mockRequests[5], mockRequests[8], mockRequests[9] }; list.Should().HaveCount(actual.Length); list.Should().Contain(actual); }
public void AssignmentFilter_ByStatusCancelled() { var filter = new AssignmentFilterModel { Status = AssignmentStatus.Cancelled }; var list = filter.Apply(mockRequests.AsQueryable(), _clock); var actual = mockRequests.Where(r => r.Order.Status == OrderStatus.CancelledByBroker || r.Order.Status == OrderStatus.CancelledByCreator ); list.Should().HaveCount(actual.Count()); list.Should().Contain(actual); }
public async Task <IActionResult> All(AssignmentFilterModel filters = null) { var user = await this.userManager.GetUserAsync(this.User); var userId = user.Id; var studentId = this.userService.GetStudentByUserId(userId).Id; var assignments = this.studentAssignmentService.GetStudentAssignmentsByStudentId(studentId); assignments = assignments.OrderByDescending(a => a.DateCreated).ToList(); if (assignments == null) { return(View(new List <StudentAssignmentStudentViewModel>())); } return(View(assignments)); }
public void AssignmentFilter_ComboByLanguageStatusRegion() { var region = Region.Regions.Where(r => r.Name == "Uppsala").Single(); var language = mockLanguages.Where(l => l.Name == "French").Single(); var filter = new AssignmentFilterModel { Status = AssignmentStatus.Executed, RegionId = region.RegionId, LanguageId = language.LanguageId, }; var list = filter.Apply(mockRequests.AsQueryable(), _clock); var actual = mockRequests.Where(r => r.Order.Region == region && r.Order.Language == language && r.Order.StartAt < _clock.SwedenNow && (r.Order.Status == OrderStatus.Delivered)); list.Should().HaveCount(actual.Count()); list.Should().Contain(actual); }
public void AssignmentFilter_ByStatusToBeReported() { var filter = new AssignmentFilterModel { Status = AssignmentStatus.ToBeReported }; var list = filter.Apply(mockRequests.AsQueryable(), _clock); var actual = mockRequests.Where(r => !r.Requisitions.Any() && r.Order.StartAt < _clock.SwedenNow && r.Status == RequestStatus.Approved); if (list.ToList().Count == 0) { actual.ToList().Count().Should().Be(0); } else { list.Should().HaveCount(actual.Count()); list.Should().Contain(actual); } }
public async Task <IActionResult> ListAssignments(IDataTablesRequest request) { var model = new AssignmentFilterModel(); await TryUpdateModelAsync(model); var requests = _dbContext.Requests.GetRequestsForInterpreter(User.GetInterpreterId()); return(AjaxDataTableHelper.GetData(request, requests.Count(), model.Apply(requests, _clock), x => x.Select(r => new RequestListItemModel { RequestId = r.RequestId, LanguageName = r.Order.OtherLanguage ?? r.Order.Language.Name, OrderNumber = r.Order.OrderNumber, CustomerName = r.Order.CustomerOrganisation.Name, RegionName = r.Order.Region.Name, ExpiresAt = r.ExpiresAt, StartAt = r.Order.StartAt, EndAt = r.Order.EndAt, Status = r.Status }))); }
public ActionResult Assignments(AssignmentFilterModel model = null) { var identityId = CurrentUserSettings.GetCurrentUser(HttpContext).ToString(); AssignmentFilter customFilter; var assignmentFilters = GenerateFilters(identityId); if (model != null && assignmentFilters.TryGetValue(model.FilterName, out var res)) { customFilter = res; if (model.DocumentNumber != null) { var doc = _documentRepository.GetByNumber((int)model.DocumentNumber); if (doc != null) { customFilter.ProcessIdEqual(doc.Id); } else { customFilter.ProcessIdEqual(Guid.Empty); } } if (model.AssignmentCode != null) { customFilter.CodeEquals(model.AssignmentCode); } if (model.StatusState != "Any") { customFilter.StatusStateEquals(model.StatusState); } } else { customFilter = new AssignmentFilter(); model = new AssignmentFilterModel() { Page = model?.Page ?? 1, PageChanged = 0 }; } int count = WorkflowInit.Runtime.PersistenceProvider.GetAssignmentCountAsync(customFilter).Result; model.Page = model?.Page ?? 1; var maxPage = Math.Ceiling(count / (decimal)pageSize); if (model.Page > maxPage) { model.Page = (int)maxPage; } List <Assignment> assignments = WorkflowInit.Runtime.AssignmentApi.GetAssignmentsAsync(customFilter, new Paging(model.Page, pageSize)).Result; var statuses = WorkflowInit.Runtime.AssignmentApi.GetAssignmentStatuses(); statuses.Add("Any"); return(View("Assignments", new AssignmentListModel() { Assignments = GetAssignmentModels(assignments), PageSize = pageSize, Count = count, Filters = assignmentFilters, CustomFilter = model, Statuses = statuses })); }
public async Task <ActionResult <IEnumerable <Assignment> > > GetFilteredAssignments(AssignmentFilterModel filtermodel) { List <Assignment> allAssignments = await _context.Assignments. Include(a => a.TagAssignments).ThenInclude(a => a.Tag) .Include(a => a.Company) .Include(a => a.Status) .Include(a => a.Location) .Include(e => e.Status).ToListAsync(); if (filtermodel.CompanyName != null && filtermodel.CompanyName != "" && filtermodel.CompanyName != " ") { allAssignments = allAssignments.Where(c => c.Company.CompanyName.ToLower().Contains(filtermodel.CompanyName.ToLower())).ToList(); } if (filtermodel.Status != null && filtermodel.Status != "" && filtermodel.Status != " ") { allAssignments = allAssignments.Where(c => c.Status.CurrentStatus.ToLower().Contains(filtermodel.Status.ToLower())).ToList(); } if (filtermodel.Title != null && filtermodel.Title != "") { allAssignments = allAssignments.Where(c => c.AssignmentName.ToLower().Contains(filtermodel.Title.ToLower())).ToList(); } return(allAssignments); }
private IList <AssignmentListViewModel> ApplyAssignmentFilters(AssignmentFilterModel filters, List <AssignmentListViewModel> assignments) { return(assignments); }
private AssignmentFilterModel GetAssignmentsWithCustomFilter() { var model = new AssignmentFilterModel() { FilterName = Request.Form[$"{Master.UniqueID}$MainContent$formFilter$FilterName"], AssignmentCode = Request.Form[$"{Master.UniqueID}$MainContent$formFilter$AssignmentCode"], StatusState = Request.Form[$"{Master.UniqueID}$MainContent$formFilter$StatusState"], Page = Int32.Parse(Request.Form[$"{Master.UniqueID}$MainContent$formFilter$Page"]), }; var isCorrect = Int32.TryParse(Request.Form[$"{Master.UniqueID}$MainContent$formFilter$DocumentNumber"], out int documentNumber); model.DocumentNumber = isCorrect ? documentNumber : (int?)null; Guid identityId = CurrentUserSettings.GetCurrentUser(); var assignmentFilters = GenerateFilters(identityId.ToString()); AssignmentFilter customFilter; if (assignmentFilters.TryGetValue(model.FilterName, out var res)) { customFilter = res; if (model.DocumentNumber != null) { var doc = DocumentRepository.GetByNumber((int)model.DocumentNumber); if (doc != null) { customFilter.ProcessIdEqual(doc.Id); } else { customFilter.ProcessIdEqual(Guid.Empty); } } if (!model.AssignmentCode.IsNullOrWhiteSpace()) { customFilter.CodeEquals(model.AssignmentCode); } if (model.StatusState != "Any") { customFilter.StatusStateEquals(model.StatusState); } } else { customFilter = new AssignmentFilter(); model = new AssignmentFilterModel() { Page = model?.Page ?? 1 }; } int count = WorkflowInit.Runtime.PersistenceProvider.GetAssignmentCountAsync(customFilter).Result; model.Page = model?.Page ?? 1; var maxPage = Math.Ceiling(count / (decimal)PageSize); if (model.Page > maxPage) { model.Page = (int)maxPage; } List <Assignment> assignments = WorkflowInit.Runtime.AssignmentApi.GetAssignmentsAsync(customFilter, new Paging(model.Page, PageSize)).Result; Count = count; PageNumber = model.Page; AssignmentsTableRepeater.DataSource = GetAssignmentModels(assignments); AssignmentsTableRepeater.DataBind(); return(model); }