//// REGISTER MANAGER ACCOUNT public static void CreateManager() { Console.Clear(); Console.WriteLine(" account manager registration"); Console.Write("enter your first name: "); string firstname = Console.ReadLine(); Console.Write("enter your last name: "); string lastname = Console.ReadLine(); Console.Write("enter your middle name: "); string middlename = Console.ReadLine(); Console.Write("enter your email: "); string email = Console.ReadLine(); Console.Write("enter your password: "******"confirm your password: "******"Manager's account created succesfully"); ManagerService.CreateManager(firstname, lastname, middlename, email, password, checkpassword); }
public async Task <ActionResult> Create(Manager manager) { if (ModelState.IsValid) { await Task.Run(() => ManagerService.CreateManager(manager)); return(RedirectToAction("Index")); } ModelState.AddModelError("", "Invalid data"); return(View("Create")); }
public void ReturnManager() { //Arrange var teamService = new Mock <ITeamService>(); var options = TestUtils.GetOptions(nameof(ReturnManager)); var firstName = "Hristo"; var lastName = "Konov"; var nationality = "Bulgarian"; //Act,Assert using (var assertContext = new FMDbContext(options)) { var sut = new ManagerService(assertContext, teamService.Object); var manager = sut.CreateManager(firstName, lastName, nationality); Assert.AreEqual(manager.FirstName, firstName); Assert.AreEqual(manager.LastName, lastName); Assert.AreEqual(manager.Nationality, nationality); Assert.AreEqual(1, assertContext.Managers.Count()); } }
/// <summary> /// I try to learn how write summary properly /// </summary> /// <param name="managerViewModel"></param> /// <returns>Json = bool</returns> public JsonResult Create(string NewManagerName) { bool result = false; if (!string.IsNullOrWhiteSpace(NewManagerName) && NewManagerName.Length > 1) { //Expression<Func<Manager, bool>> expression = ; var exp = new Expression <Func <Manager, bool> >[] { (manager) => manager.Name == NewManagerName }; if (_managerService.GetManagers(exp).Count() == 0) { _managerService.CreateManager(new Manager { Name = NewManagerName }); result = true; } } return(Json(result)); }
static void Main(string[] args) { DirectorModel director = Serializer.Deserialize("Company.json"); IClientService clientService = new ClientService(director); IManagerService managerService = new ManagerService(director); IDirectorService directorService = new DirectorService(director); Console.Write("client$ "); while (true) { string command = Console.ReadLine(); if (command == "+") { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Position: "); string position = Console.ReadLine(); Console.Write("Salary: "); int salary = Int32.Parse(Console.ReadLine()); string[] words = position.ToLower().Split(new char[] { ' ' }); foreach (var item in words) { if (item == "manager") { Console.WriteLine(managerService.CreateManager(name, position, salary).Name); } if (item == "worker") { Console.WriteLine(clientService.AddEmployee(name, position, salary).Name); } if (item == "director") { Console.WriteLine(directorService.CreateDirector(name, position, salary).Name); } } } if (command == "straight") { StraightStructureStrategy straightStructure = new StraightStructureStrategy(); List <EmployeeModel> result = straightStructure.BuildStructure(director); foreach (var item in result) { Console.WriteLine(item.Name); } } if (command == "height") { PositionHeightStructureStrategy positionHeight = new PositionHeightStructureStrategy(); List <EmployeeModel> result = positionHeight.BuildStructure(director); foreach (var item in result) { Console.WriteLine(item.Name); } } if (command == "find max") { EmployeeModel result = clientService.FindEmployeeWithMaxSalary(); Console.WriteLine("{0} {1}", result.Name, result.Salary); } if (command == "find bigger") { Console.Write("Enter int number: "); int value = Int32.Parse(Console.ReadLine()); List <EmployeeModel> resultEmployees = clientService.FindEmployeesWithBiggerSalary(value); foreach (var item in resultEmployees) { Console.WriteLine("{0} : {1}, ", item.Name, item.Salary); } } if (command == "subordinates") { Console.Write("Enter name: "); string enteredName = Console.ReadLine(); List <WorkerModel> resultedEmployees = clientService.FindSubordinates(enteredName); foreach (var item in resultedEmployees) { Console.WriteLine(item.Name); } } if (command == "find position") { Console.Write("Position: "); string enteredValue = Console.ReadLine(); List <EmployeeModel> resultEmployees = clientService.FindByPosition(enteredValue); foreach (var item in resultEmployees) { Console.WriteLine(item.Name); } } if (command == "add sub") { Console.WriteLine("To manager or director? m or n"); string input = Console.ReadLine(); if (input == "m") { Console.Write("Daddy: "); string daddyName = Console.ReadLine(); Console.Write("Child: "); string childName = Console.ReadLine(); managerService.AddSubordinate(daddyName, childName); } if (input == "d") { Console.Write("Child: "); string childName = Console.ReadLine(); directorService.AddSubordinate(director, childName); } } if (command == "remove sub") { Console.WriteLine("To manager or director? m or n"); string input = Console.ReadLine(); if (input == "m") { Console.Write("Daddy: "); string daddyName = Console.ReadLine(); Console.Write("Child: "); string childName = Console.ReadLine(); managerService.RemoveSubordinate(daddyName, childName); } if (input == "d") { Console.Write("Child: "); string childName = Console.ReadLine(); directorService.RemoveSubordinate(director, childName); } } if (command == "exit") { Console.WriteLine("Save changes? y or n"); string input = Console.ReadLine(); if (input == "y") { Serializer.Serialize(director); break; } else { Environment.Exit(0); } } if (command == "help") { Console.Write("+ to add new worker \n straight to build straight position structure " + "\n height to build position height structure" + "\n find max to find employee with max salary" + "\n find bigger find employees with bigger wage than you entered" + "\n subordinates to output subordinates of given employee (only manager)" + "\n find position finds all employes within given position" + "\n add sub adds subordinate to given supervisor" + "\n remove sub removes subordinate" + "\n exit \n"); } Console.Write("client$ "); } }