public void getSubordinatesTest_EmptyRoles() { //Arrange List <User> users = new List <User> { new User { Id = 1, Name = "Adam Admin", Role = 1 }, new User { Id = 2, Name = "Emily Employee", Role = 4 }, new User { Id = 3, Name = "Sam Supervisor", Role = 3 }, new User { Id = 4, Name = "Mary Manager", Role = 2 }, new User { Id = 5, Name = "Steve Trainer", Role = 5 } }; //Act Subordinates subordinates = new Subordinates(1, new List <Role>(), users); var results = subordinates.getSubordinates(); //Assert Assert.AreEqual(results.Count, 0); }
public void getSubordinatesTest_EmptyUsers() { //Arrange List <Role> roles = new List <Role> { new Role { Id = 1, Name = "System Administrator", Parent = 0 }, new Role { Id = 2, Name = "Location Manager", Parent = 1 }, new Role { Id = 3, Name = "Supervisor", Parent = 2 }, new Role { Id = 4, Name = "Employee", Parent = 3 }, new Role { Id = 5, Name = "Trainer", Parent = 3 } }; //Act Subordinates subordinates = new Subordinates(1, roles, new List <User>()); var results = subordinates.getSubordinates(); //Assert Assert.AreEqual(results.Count, 0); }
public double calculateSal(DateTime date) { int years = getYears(date, HireDate); double nGrowth = growth * years; if (nGrowth > limit) { nGrowth = limit; } double sal = 0; if (Subordinates != null) { int count = 0; count = Subordinates.Count(); for (int i = 0; i < count; i++) { //В случае если надбавка за подчиненных считается с базовой ставки заменить метод calculateSal(date) на .Salary sal += Subordinates[i].calculateSal(date); } } double res = 0; res = Salary + Salary * nGrowth + sal * subGrowth; return(res); }
public void getSubordinatesTest_UserId_3() { //Arrange List <Role> roles = new List <Role> { new Role { Id = 1, Name = "System Administrator", Parent = 0 }, new Role { Id = 2, Name = "Location Manager", Parent = 1 }, new Role { Id = 3, Name = "Supervisor", Parent = 2 }, new Role { Id = 4, Name = "Employee", Parent = 3 }, new Role { Id = 5, Name = "Trainer", Parent = 3 } }; List <User> users = new List <User> { new User { Id = 1, Name = "Adam Admin", Role = 1 }, new User { Id = 2, Name = "Emily Employee", Role = 4 }, new User { Id = 3, Name = "Sam Supervisor", Role = 3 }, new User { Id = 4, Name = "Mary Manager", Role = 2 }, new User { Id = 5, Name = "Steve Trainer", Role = 5 } }; List <User> suborindatesUsers = new List <User> { new User { Id = 2, Name = "Emily Employee", Role = 4 }, new User { Id = 5, Name = "Steve Trainer", Role = 5 } }; //Act Subordinates subordinates = new Subordinates(3, roles, users); string actualUsers = JsonSerializer.Serialize(subordinates.getSubordinates()); string expectedUsers = JsonSerializer.Serialize(suborindatesUsers); //Assert Assert.AreEqual(expectedUsers, actualUsers); }
public override decimal CalcSalary() { var salary_as_employee = base.CalcSalary(); var subordinate_percents = Subordinates.Sum(s => s.CalcSalary()) / 100 * SUBORDINATE_PERCENTS; return(salary_as_employee + subordinate_percents); }
public void addSubordinate(Staff subordinate) { if (Subordinates != null && subordinate != null) { Subordinates.Add(subordinate); } }
public void DeleteWithSubordinates() { foreach (Employee employee in Subordinates.Clone()) { employee.Delete(); } this.Delete(); }
public void getSubordinatesTest_EmptyRolesAndUsers() { //Arrange & Act Subordinates subordinates = new Subordinates(1, new List <Role>(), new List <User>()); var results = subordinates.getSubordinates(); //Assert Assert.AreEqual(results.Count, 0); }
protected override decimal CalculateSalary(DateTime salaryDate, SalaryBuilder builder) { int periodInMonthes = DateTimeHelper.GetDifferenceInMonthes(jobStartDate, salaryDate); int numYears = periodInMonthes / 12; IEnumerable <Worker> subordinates = Subordinates.Select(s => s.Worker); builder.ApplyYearsRate(numYears, 0.01m, 0.35m); builder.ApplySubordinatorsRate(salaryDate, 0.03m, subordinates); return(periodInMonthes * builder.Salary); }
public async Task <IActionResult> BankDetails([Bind("ID,BankName,BankAddress,IBAN,SortCode")] Subordinates model) { if (ModelState.IsValid)//Server side validation { _context.Add(model); await _context.SaveChangesAsync(); return(View("BankDetails", model)); } return(View("Subordinates", model)); }
public async Task <IActionResult> AddSubordinates([Bind("ID,FirstName,LastName,Occupation")] Subordinates model) { if (ModelState.IsValid)//Server side validation { _context.Add(model); await _context.SaveChangesAsync(); return(View("SubordinateDetails", model)); } return(View("Subordinates", model)); }
static void Main(string[] args) { //default input file is D:\input.txt + an option to change it once string inputFilePath = @"D:\input.txt"; Console.Write("Defualt input file path is: " + inputFilePath + "... Would you like to change it? (y/n): "); if (Console.ReadLine().Equals("y")) { Console.Write("Please enter the new path: "); string newFile = Console.ReadLine(); if (File.Exists(newFile)) { inputFilePath = newFile; } else { Console.WriteLine("Failed to change default path"); } } if (File.Exists(inputFilePath)) { bool moreRounds = true; while (moreRounds) { Group group = new Group(inputFilePath); Console.Write("Enter User Id: "); if (int.TryParse(Console.ReadLine(), out int userNum)) { Subordinates subordinates = new Subordinates(userNum, group.Roles, group.Users); Console.WriteLine(JsonSerializer.Serialize(subordinates.getSubordinates(), new JsonSerializerOptions { WriteIndented = true })); //File.WriteAllText(@"D:\UsersOutput.txt", JsonSerializer.Serialize(subordinates.getSubordinates(), new JsonSerializerOptions { WriteIndented = true })); } else { Console.WriteLine("Invalid User Id"); } Console.Write("One more go? (y/n): "); moreRounds = Console.ReadLine().ToLower().Equals("y"); } } else { Console.WriteLine("Input file does not exist!"); Console.ReadLine(); } }
public void getSubordinatesTest_UserId_0() { //Arrange List <Role> roles = new List <Role> { new Role { Id = 1, Name = "System Administrator", Parent = 0 }, new Role { Id = 2, Name = "Location Manager", Parent = 1 }, new Role { Id = 3, Name = "Supervisor", Parent = 2 }, new Role { Id = 4, Name = "Employee", Parent = 3 }, new Role { Id = 5, Name = "Trainer", Parent = 3 } }; List <User> users = new List <User> { new User { Id = 1, Name = "Adam Admin", Role = 1 }, new User { Id = 2, Name = "Emily Employee", Role = 4 }, new User { Id = 3, Name = "Sam Supervisor", Role = 3 }, new User { Id = 4, Name = "Mary Manager", Role = 2 }, new User { Id = 5, Name = "Steve Trainer", Role = 5 } }; //Act Subordinates subordinates = new Subordinates(0, roles, users); var results = subordinates.getSubordinates(); //Assert Assert.AreEqual(results.Count, 0); }
private async Task <IActionResult> EditSubordinate(int?id) { if (id == null) { return(NotFound()); } var user = await _context.Subordinates .Include(i => i.SubordinateModules) .AsNoTracking() .SingleOrDefaultAsync(m => m.ID == id); var modules = from m in _context.Module select new { m.ModuleID, m.Name, Checked = ((from sb in _context.SubordinateModules where (sb.SubordinateID == id) & (sb.ModuleID == m.ModuleID) select sb).Count() > 0) }; var subordinate = new Subordinates(); subordinate.ID = id.Value; subordinate.FirstName = user.FirstName; subordinate.LastName = user.LastName; var CheckboxList = new List <CheckboxViewModel>(); foreach (var module in modules) { CheckboxList.Add(new CheckboxViewModel { ID = module.ModuleID, ModuleName = module.Name, Checked = module.Checked }); } subordinate.Modules = CheckboxList; if (user == null) { return(NotFound()); } return(View(subordinate)); // (user) }
public double countSub(DateTime date) { double sal = 0; if (Subordinates != null) { int count = 0; count = Subordinates.Count(); for (int i = 0; i < count; i++) { sal += Subordinates[i].calculateSal(date); if (!Subordinates[i].Position.Equals("employee")) { double ssal = Subordinates[i].countSub(date); sal += ssal; } } } return(sal); }
public override bool Equals(object obj) { var other = obj as Employee; if (other == null) { return(false); } return(Id == other.Id && FirstName == other.FirstName && LastName == other.LastName && BirthDate == other.BirthDate && ManagerId == other.ManagerId && CompanyId == other.CompanyId && Company.NullSafeIdEquals(other.Company, x => x.Id) && Manager.NullSafeIdEquals(other.Manager, x => x.Id) && Mentor.NullSafeIdEquals(other.Mentor, x => x.Id) && Subordinates.Select(x => x.Id).ElementEquals(other.Subordinates.Select(x => x.Id)) && Mentees.Select(x => x.Id).ElementEquals(other.Mentees.Select(x => x.Id))); }
public void AddSubordinate(Employee subordinate) { Subordinates.Add(subordinate); subordinate.Manager = this; subordinate.RefreshReferencedIds(); }
// Remove child from subordinates public override void RemoveChild(NavyComponent subordinate) { Subordinates.Remove(subordinate); }
// Add child to subordinates public override void AddChild(NavyComponent subordinate) { Subordinates.Add(subordinate); }
public void Add(IWorker worker) { Subordinates.Add(worker); }
partial void DeassignSubordinate_Execute() { Engineer.Subordinates.Remove(Subordinates.SelectedItem); this.Save(); Subordinates.Refresh(); }
//Listing 11-15. Assigning and deassigning subordinates partial void AssignSubordinate_Execute() { Engineer.Subordinates.Add(EngineerToAdd); this.Save(); Subordinates.Refresh(); }
public void Remove(IWorker worker) { Subordinates.Remove(worker); }
public void AddSubordinate(Position position) { Subordinates.Add(position); position.Supervisor = this; }
// // Manager interface // public void RemoveSubordinate(Position position) { Subordinates.Remove(position); position.Supervisor = null; }
private decimal GetSalaryPrivate(DateTime date, IDictionary <int, decimal> salaries) { return(base.GetSalary(date) + EmployeesBonusRate * Subordinates.Sum(e => e.GetSalary(date, salaries))); }
public async Task <IActionResult> Update(SubordinateMod updateduser) { EManager3User user = await userManager.FindByIdAsync(updateduser.Id); if (user != null) { user.Email = updateduser.Email; user.UserName = updateduser.Email; user.FirstName = updateduser.FirstName; user.LastName = updateduser.LastName; user.Sex = updateduser.Sex; user.DOB = updateduser.DOB; user.MaritalStatus = updateduser.MaritalStatus; user.isActive = updateduser.isActive; user.NumberOfChildren = updateduser.NumberOfChildren; user.EmploymentDate = updateduser.EmploymentDate; user.HighestEducationQualification = updateduser.HighestEducationQualification; user.School = updateduser.School; user.ServiceYear = updateduser.ServiceYear; user.CompanyPosition = updateduser.CompanyPosition; user.LastPromotionDate = updateduser.LastPromotionDate; user.YearlySalary = Convert.ToInt32(updateduser.YearlySalary); if (!string.IsNullOrEmpty(updateduser.Email) && !string.IsNullOrEmpty(updateduser.FirstName) && !string.IsNullOrEmpty(updateduser.LastName) && !string.IsNullOrEmpty(updateduser.Sex) && !string.IsNullOrEmpty(updateduser.MaritalStatus)) { IdentityResult result = await userManager.UpdateAsync(user); if (result.Succeeded) { var result2 = _context.Subordinates.Where(x => x.UserId == updateduser.Id).ToList(); foreach (var sub in result2) { _context.Subordinates.Remove(sub); } await _context.SaveChangesAsync(); foreach (var newsub in updateduser.AddIds ?? new string[] { }) { var subs = new Subordinates { UserId = updateduser.Id, SubordinateId = newsub }; _context.Subordinates.Add(subs); } await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } else { Errors(result); } } } else { ModelState.AddModelError("", "User Not Found"); } return(View(user)); }
public override void Remove(PersonComponent subordinate) { Subordinates.Remove(subordinate); }
//public List<PersonComponent> Subordinates { get; set; } = new List<PersonComponent>(); public override void Add(PersonComponent subordinate) { Subordinates.Add(subordinate); }