public async Task TestEmployerRepositoryReturnsList() { var employerRepository = new EmployerRepository(); var actual = await employerRepository.GetAll().ConfigureAwait(false); Assert.IsNotNull(actual); Assert.IsTrue(actual.Any()); }
public async Task <IActionResult> Index(int id) { Pagination(id); var users = await _repository.GetAll(id).ToListAsync();// await _context.User.Skip(id * 15).Take(15).ToListAsync(); var UsersView = users.Select(x => new UserViewModel { ID = x.UserId, Name = x.Name, Surname = x.Surname, NetSalary = x.Salary, GroosSalary = NetGrossCalculator.CalculateGross(x.Salary) }).ToList(); return(View("Index", UsersView)); }
public void RefreshGui() { dpmRepo.GetAll(); List <SoloDepartment> departments = dpmRepo.GetAll().ToList(); empRepo.GetAll(); List <SoloEmployer> employees = empRepo.GetAll().ToList(); salRepo.GetAll(); List <SoloSalary> salaries = salRepo.GetAll().ToList(); if (empRepo == null && dpmRepo == null && salRepo == null) { return; //negated protection as in other forms } int selectedRowComfortGui; //for user comfort try { //multiselect should be take in account selectedRowComfortGui = repDataGridView.CurrentCell.RowIndex; } catch { selectedRowComfortGui = 0; } repDataGridView.ClearSelection(); //cleaning previos search repDataGridView.Columns.Clear(); //cleaning previous content repDataGridView.Rows.Clear(); //cleaning previous content /* * I dont want to refactor this code, but better way how to use object model is shown in part Refresh stats */ //columns headers DataGridViewColumn d1 = new DataGridViewTextBoxColumn(); d1.HeaderText = "ID employee"; d1.ReadOnly = true; d1.Visible = false; d1.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d2 = new DataGridViewTextBoxColumn(); d2.HeaderText = "First name"; d2.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d3 = new DataGridViewTextBoxColumn(); d3.HeaderText = "Middle name"; d3.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d4 = new DataGridViewTextBoxColumn(); d4.HeaderText = "Last name"; d4.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d5 = new DataGridViewTextBoxColumn(); d5.HeaderText = "Email contact"; d5.SortMode = DataGridViewColumnSortMode.Automatic; d5.Visible = false; DataGridViewColumn d6 = new DataGridViewComboBoxColumn(); d6.HeaderText = "Department"; d6.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d7 = new DataGridViewTextBoxColumn(); d7.HeaderText = "Salary value"; d7.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d8 = new DataGridViewTextBoxColumn(); d8.HeaderText = "Valid from"; d8.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d9 = new DataGridViewTextBoxColumn(); d9.HeaderText = "Valid to"; d9.SortMode = DataGridViewColumnSortMode.Automatic; repDataGridView.Columns.AddRange(d1, d2, d3, d4, d5, d6, d7, d8, d9); foreach (SoloEmployer emp in employees) { var row = new DataGridViewRow(); row.Cells.Add(new DataGridViewTextBoxCell { Value = emp.ID }); row.Cells.Add(new DataGridViewTextBoxCell { Value = emp.Name1 }); row.Cells.Add(new DataGridViewTextBoxCell { Value = emp.Name2 }); row.Cells.Add(new DataGridViewTextBoxCell { Value = emp.Name3 }); row.Cells.Add(new DataGridViewTextBoxCell { Value = emp.Email }); DataGridViewComboBoxCell dgvCB = new DataGridViewComboBoxCell(); dgvCB.DataSource = dpmRepo.getComboBoxSource(); dgvCB.Value = emp.IDdmp; dgvCB.ValueMember = "IDdpm"; dgvCB.DisplayMember = "Name"; row.Cells.Add(dgvCB); //comboBox to building row SoloSalary sa = new SoloSalary(); foreach (SoloSalary ssa in salaries) //woraround, SELECT WHERE IDemp is not implicitely working { if (ssa.IDemp == emp.ID) { sa = ssa; } } row.Cells.Add(new DataGridViewTextBoxCell { Value = sa.Amount }); DateTime validFrom = sa.validFrom, validTo = sa.validUntil; //parsing datetime to be showed string validFromUI, validToUI; if (validFrom == DateTime.MinValue || validTo == DateTime.MinValue) { validFromUI = ""; validToUI = ""; } else { validFromUI = validFrom.ToString(dateTimeFormat); validToUI = validTo.ToString(dateTimeFormat); } row.Cells.Add(new DataGridViewTextBoxCell { Value = validFromUI }); row.Cells.Add(new DataGridViewTextBoxCell { Value = validToUI }); repDataGridView.Rows.Add(row); //finalize row } repDataGridView.Rows[selectedRowComfortGui].Selected = true; RefreshStats(); }
public void RefreshGui() { empRepo = new EmployerRepository(); //contains data empRepo.GetAll(); if (empRepo != null && dpmRepo != null) { List <SoloEmployer> employees = empRepo.GetAll().ToList(); var departments = dpmRepo.GetAll(); int selectedRowComfortGui; //for user comfort try { selectedRowComfortGui = empDataGridView.CurrentCell.RowIndex; } catch { selectedRowComfortGui = 0; } empDataGridView.ClearSelection(); //cleaning previos search empDataGridView.Columns.Clear(); //cleaning previous content empDataGridView.Rows.Clear(); //cleaning previous content //columns headers DataGridViewColumn d1 = new DataGridViewTextBoxColumn(); d1.HeaderText = "ID employee"; d1.ReadOnly = true; d1.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d2 = new DataGridViewTextBoxColumn(); d2.HeaderText = "First name"; d2.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d3 = new DataGridViewTextBoxColumn(); d3.HeaderText = "Middle name"; d3.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d4 = new DataGridViewTextBoxColumn(); d4.HeaderText = "Last name"; d4.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d5 = new DataGridViewTextBoxColumn(); d5.HeaderText = "Email contact"; d5.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d6 = new DataGridViewComboBoxColumn(); d6.HeaderText = "Department"; d6.SortMode = DataGridViewColumnSortMode.Automatic; empDataGridView.Columns.AddRange(d1, d2, d3, d4, d5, d6); foreach (SoloEmployer emp in employees) { var row = new DataGridViewRow(); row.Cells.Add(new DataGridViewTextBoxCell { Value = emp.ID }); row.Cells.Add(new DataGridViewTextBoxCell { Value = emp.Name1 }); row.Cells.Add(new DataGridViewTextBoxCell { Value = emp.Name2 }); row.Cells.Add(new DataGridViewTextBoxCell { Value = emp.Name3 }); row.Cells.Add(new DataGridViewTextBoxCell { Value = emp.Email }); /* * string nameOfDepartmentForEmp = "uknown name of departement"; * foreach(SoloDepartment sd in departments) * { * if (sd.IDdpm == emp.IDdmp) * { * nameOfDepartmentForEmp = sd.Name; * break; * } * } */ DataGridViewComboBoxCell dgvCB = new DataGridViewComboBoxCell(); dgvCB.DataSource = dpmRepo.getComboBoxSource(); dgvCB.Value = emp.IDdmp; dgvCB.ValueMember = "IDdpm"; dgvCB.DisplayMember = "Name"; row.Cells.Add(dgvCB); //comboBox to building row empDataGridView.Rows.Add(row); //finalize row } empDataGridView.Rows[selectedRowComfortGui].Selected = true; } }
public void RefreshGui() { salRepo = new SalaryRepository(); //contains data salRepo.GetAll(); if (empRepo != null && salRepo != null) { List <SoloSalary> salaries = salRepo.GetAll().ToList(); var employees = empRepo.GetAll(); int selectedRowComfortGui; //for user comfort try { selectedRowComfortGui = salDataGridView.CurrentCell.RowIndex; } catch { selectedRowComfortGui = 0; } salDataGridView.ClearSelection(); //cleaning previos search salDataGridView.Columns.Clear(); //cleaning previous content salDataGridView.Rows.Clear(); //cleaning previous content //columns headers DataGridViewColumn d1 = new DataGridViewTextBoxColumn(); d1.HeaderText = "ID"; d1.Visible = false; d1.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d2 = new DataGridViewTextBoxColumn(); d2.HeaderText = "Employee"; d2.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d3 = new DataGridViewTextBoxColumn(); d3.HeaderText = "Amount €"; d3.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d4 = new DataGridViewTextBoxColumn(); d4.HeaderText = "Earn from"; d4.SortMode = DataGridViewColumnSortMode.Automatic; DataGridViewColumn d5 = new DataGridViewTextBoxColumn(); d5.HeaderText = "Earn to"; d5.SortMode = DataGridViewColumnSortMode.Automatic; salDataGridView.Columns.AddRange(d1, d2, d3, d4, d5); foreach (SoloSalary sal in salaries) { var row = new DataGridViewRow(); row.Cells.Add(new DataGridViewTextBoxCell { Value = sal.IDsal }); SoloEmployer se = empRepo.GetByID(sal.IDemp); row.Cells.Add(new DataGridViewTextBoxCell { Value = se.Name1 + " " + se.Name2 + " " + se.Name3 }); row.Cells.Add(new DataGridViewTextBoxCell { Value = sal.Amount }); row.Cells.Add(new DataGridViewTextBoxCell { Value = sal.validFrom.ToString(dateTimeFormat) }); row.Cells.Add(new DataGridViewTextBoxCell { Value = sal.validUntil.ToString(dateTimeFormat) }); salDataGridView.Rows.Add(row); //finalize row } salDataGridView.Rows[selectedRowComfortGui].Selected = true; } }