public void TestRepositoryPaging2() { EmployeeRepository ep = RepositoryHelper.GetEmployeeRepository(); PagedList <Employee> pageset = ep.All().OrderBy(e => e.EmployeeID).AsQueryable().ToPagedList(1, 10); Assert.NotNull(pageset); Assert.Equal(10, pageset.Count()); }
// GET: Animals/PetForm public ActionResult PetForm(string biteId, string petId) { var PetFormViewModel = new AnimalViewModel { Animal = new Animal(biteId), Breeds = _breedRepository.All(), Specieses = _speciesRepository.All(), Employees = _employeeRepository.All(), Vets = _vetRepository.All() }; if (petId != null) { PetFormViewModel.Animal = _animalRepository.GetById(petId).Result; } return(View(PetFormViewModel)); }
// GET: Employee public ActionResult Index() { using (IEmployeeRepository _employeeRepo = new EmployeeRepository(ApplicationDbContext.Create())) { EmployeesViewModel viewModel = new EmployeesViewModel() { Employees = _employeeRepo.All().ToList() }; return(View(viewModel)); } }
// GET: Employee public ActionResult Index() { var test = _employee.All().Include(s => s.Department).Select(s => new { EmployeeId = s.Id, DeptName = s.Department.Name }); var employees = _employee.GetAll(); return(View(employees.ToList())); }
public ActionResult Index(int?EmployeeId) { IEnumerable <EmployeeModel> result; if (EmployeeId == null) { result = EmployeeRepository.All().Where(e => e.ReportsTo == null); } else { result = EmployeeRepository.All().Where(e => e.ReportsTo == Convert.ToInt32(EmployeeId)); } return(this.Jsonp(result)); }
public async Task <ActionResult> BiteForm(string id) { var biteViewModel = new BiteViewModel { Bite = new Bite(), Cities = _citiesRepository.All(), States = _statesRepository.All(), Employees = _employeeRepository.All(), BiteStatuses = _biteStatusRepository.All() }; if (id != null) { biteViewModel.Bite = await _biteRepository.GetById(id); if (biteViewModel.Bite == null) { return(HttpNotFound()); } } return(View(biteViewModel)); }
public ActionResult Index() { HomeViewModel viewModel = null; using (ICustomerRepository _customerRepo = new CustomerRepository(ApplicationDbContext.Create())) using (IEmployeeRepository _employeeRepo = new EmployeeRepository(ApplicationDbContext.Create())) using (IPostItRepository _postItRepo = new PostItRepository(ApplicationDbContext.Create())) { List <Template> templates = new List <Template>(); for (int i = 1; i < 3; i++) { Template template = new Template() { TemplateId = i, TemplateName = "Template - Uge " + i }; templates.Add(template); } var employees = _employeeRepo.All(); List <EmployeeHelpModel> employeeHelpModels = new List <EmployeeHelpModel>(); EmployeeHelpModel all = new EmployeeHelpModel() { Id = -1, Name = "Alle" }; employeeHelpModels.Add(all); foreach (var employee in employees) { EmployeeHelpModel helpModel = new EmployeeHelpModel() { Id = employee.EmployeeId, Name = employee.Name }; employeeHelpModels.Add(helpModel); } viewModel = new HomeViewModel() { Customers = _customerRepo.All().ToList(), Employees = employees.ToList(), EmployeesList2 = employeeHelpModels, Templates = templates }; } return(View(viewModel)); }
public ActionResult Search(int?EmployeeId, string text) { IEnumerable <EmployeeModel> result; result = EmployeeRepository.All() .Where(e => EmployeeId == null ? e.ReportsTo == null : e.ReportsTo == Convert.ToInt32(EmployeeId)) .Where(e => string.IsNullOrEmpty(text) || e.FullName.Contains(text) || (EmployeeRepository.All() .Where(q => q.ReportsTo == e.EmployeeId && (q.FullName.Contains(text) || (EmployeeRepository.All() .Where(p => p.ReportsTo == q.EmployeeId && (p.FullName.Contains(text))) ).Count() > 0)) ).Count() > 0); return(this.Jsonp(result)); }
internal List <SelectListItem> GetEmployeeSelectList(string employeeSelected) { EmployeeRepository repoEmployee = RepositoryHelper.GetEmployeeRepository(); var query = repoEmployee.All(); List <SelectListItem> slResult = new List <SelectListItem>(); foreach (var c in query) { slResult.Add(new SelectListItem() { Text = c.Name, Value = c.ADLoginID, Selected = c.ADLoginID.Equals(employeeSelected) }); } repoEmployee.UnitOfWork.Context.Dispose(); return(slResult); }
public void ShouldExecuteAllEmployeeRulesAgainstAllEmployees() { //arrange List <Employee> employees = new EmployeeRepository().GetEmployeesWithDepartmentIDs(); employees[2].DepartmentID = 0; //change to a nonsense dept id so that one of the rules breaks List <Rule <Employee> > employeeRules = new EmployeeRules().GetAllRules(); Employee lastEmployee = employees[2]; //act bool allEmployeesAreValid = employees.All(e => employeeRules.All(r => r.Test(e))); IEnumerable <Rule <Employee> > failedEmployeeRules = employeeRules.Where(r => r.Test(lastEmployee) == false); string errorMessages = failedEmployeeRules.Aggregate(new StringBuilder(), (sb, r) => sb.AppendLine(r.Message), sb => sb.ToString()); //assert allEmployeesAreValid.Should().BeFalse(); errorMessages.Should().NotBeNullOrWhiteSpace(); errorMessages.Should().Contain("Employee must have an assigned department"); }
public IEnumerable <Employee> GetAll() { return(_repository.All()); }