// Operate on Employee public EmployeeContract[] GetAllEmployees() { EmployeeContract[] employees = null; using (var db = new TimeManagerContext()) { try { var query = from e in db.Employees orderby e.FirstName select e; employees = new EmployeeContract[query.Count()]; int counter = 0; foreach (var item in query) { employees[counter] = new EmployeeContract { EmployeeId = item.EmployeeId, FirstName = item.FirstName, LastName = item.LastName }; counter++; } } catch (Exception ex) { // throw new FaultException<string> Console.WriteLine(ex.Message); } } return(employees); }
public bool PlaceEmployee(EmployeeContract employee) { using (var db = new TimeManagerContext()) { try { var existEmployee = from e in db.Employees where e.FirstName == employee.FirstName && e.LastName == employee.LastName select e; if (existEmployee.Count() == 0) { db.Employees.Add(new Employee { FirstName = employee.FirstName, LastName = employee.LastName }); db.SaveChanges(); } else { return(false); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(true); }
public static DAL.DataModel.Employee ToDomain(EmployeeContract employeeContract) { if (employeeContract != null) { DAL.DataModel.Employee employee = new DAL.DataModel.Employee { Id = employeeContract.ID, FName = employeeContract.FName, LName = employeeContract.LName, Gender = employeeContract.Gender, Addresses = new DAL.DataModel.Address[] { new DAL.DataModel.Address { Id = employeeContract.Address.Id, EmployeeId = employeeContract.Address.EmployeeContractId, Line1 = employeeContract.Address.Line1, Line2 = employeeContract.Address.Line2, POBox = employeeContract.Address.POBox, City = employeeContract.Address.City, Country = employeeContract.Address.Country, Email = employeeContract.Address.Email, Phone = employeeContract.Address.Phone, } } }; return(employee); } return(null); }
public static EmployeeContract ToContract(DAL.DataModel.Employee employee) { if (employee != null) { EmployeeContract employeeContract = new EmployeeContract { ID = employee.Id, FName = employee.FName, LName = employee.LName, Gender = employee.Gender, Address = new AddressContract { Id = employee.Addresses.FirstOrDefault().Id, EmployeeContractId = employee.Addresses.FirstOrDefault().EmployeeId, Line1 = employee.Addresses.FirstOrDefault().Line1, Line2 = employee.Addresses.FirstOrDefault().Line2, POBox = employee.Addresses.FirstOrDefault().POBox, City = employee.Addresses.FirstOrDefault().City, Country = employee.Addresses.FirstOrDefault().Country, Email = employee.Addresses.FirstOrDefault().Email, Phone = employee.Addresses.FirstOrDefault().Phone, } }; return(employeeContract); } return(null); }
public async Task <bool> EmployeeContractAlreadyExists(string contractCode) { EmployeeContract contract = await ApplicationDbContext.Set <EmployeeContract>() .FindAsync(contractCode); return(contract != null); }
public UnbreakContract(EmployeeContract contract) { BeginDate = contract.ContractBegin; EndDate = contract.ContractEnd; _Contracts.Add(contract); NextContract = null; }
public List <EmployeeContract> GetEmployeeFromTextFile(string filePath) { try { using (StreamReader sr = new StreamReader(filePath)) { List <EmployeeContract> employeeList = new List <EmployeeContract>(); string line; string[] column; int counter = 0; while ((line = sr.ReadLine()) != null) { column = line.Split('|'); EmployeeContract employee = new EmployeeContract() { ID = Convert.ToInt32(column[0]), Name = column[1], Email = column[2] }; employeeList.Add(employee); } return(employeeList); } } catch (Exception e) { throw new Exception("The file could not be read:" + e.Message); } }
private async Task DoWork(CancellationToken stoppingToken) { using IServiceScope scope = ServiceProvider.CreateScope(); EmployeeContract employeeContractProcessingService = scope.ServiceProvider.GetRequiredService <EmployeeContract>(); await employeeContractProcessingService.DoWork(stoppingToken); }
public void Update_ExistingEmployeeContract_inDB() { //Arrange EmployeeContract employeeContract = new EmployeeContract { ID = 2, FName = "Test2", LName = "User2", Gender = "M", Address = new AddressContract { Id = 2, EmployeeContractId = 2, Line1 = "Address211", Line2 = "Address212", POBox = "POBox", City = "City", Country = "Country", Email = "*****@*****.**", Phone = "+22-2222-222-222" } }; List <Employee> lst = new List <Employee> { new Employee { Id = 1, FName = "Test1", LName = "User1", Gender = "M", Addresses = new List <Address> { new Address { Id = 1, EmployeeId = 1, Line1 = "Address11", Line2 = "Address12", POBox = "POBox", City = "City", Country = "Country", Email = "*****@*****.**", Phone = "+11-1111-111-111" } } }, new Employee { Id = 2, FName = "Test2", LName = "User2", Gender = "M", Addresses = new List <Address> { new Address { Id = 2, EmployeeId = 2, Line1 = "Address21", Line2 = "Address22", POBox = "POBox", City = "City", Country = "Country", Email = "*****@*****.**", Phone = "+22-2222-222-222" } } }, new Employee { Id = 3, FName = "Test3", LName = "User3", Gender = "M", Addresses = new List <Address> { new Address { Id = 3, EmployeeId = 3, Line1 = "Address31", Line2 = "Address32", POBox = "POBox", City = "City", Country = "Country", Email = "*****@*****.**", Phone = "+33-3333-333-333" } } } }; //Arrange Mock <IEmployeeRepository> employeeRepository = new Mock <IEmployeeRepository>(); employeeRepository.Setup(x => x.GetAll()).Returns(lst); EmployeeService service = new EmployeeService(employeeRepository.Object); ////ACT Task <EmployeeContract> result = service.UpdateAsync(employeeContract); result.Wait(); //Assert Assert.Null(result.Result); }
public static Employee ToEntity(this EmployeeContract employee) { return(new Employee { Id = employee.Id, Name = employee.Name, City = employee.City }); }
public EmployeeContractDlg(int id, IUnitOfWork uow) { this.Build(); UoW = uow; Entity = (EmployeeContract)UoW.GetById(typeof(EmployeeContract), id); TabName = Entity.Name + "договор"; ConfigureDlg(); this.ShowAll(); }
public EditAssignEmployeeViewModel(EmployeeContract employeeContract) { this.ContractorID = employeeContract.Contract.ContractorID; this.EmployeeContractID = employeeContract.EmployeeContractID; this.EmployeeID = employeeContract.EmployeeID; this.ContractID = employeeContract.ContractID; //employeeContract.Contract.ContractorID //this.DocumentationDesc = docuBusinessType.Documentation.DocumentationCode + " - (" + docuBusinessType.Documentation.Description + ")"; }
public bool AddNewContractToEmployee(Employee e, EmployeeContract c) { if (GetEmployee(e.EmployeeNumber) != null) { e.employmentInfo.AddNewContract(c); dbman.InsertNewContractToDB(c); return(true); } return(false); }
public EmployeeContractViewModel(EmployeeContract employeeContract) { this.EmployeeContractID = employeeContract.EmployeeContractID; this.EmployeeID = employeeContract.EmployeeID; this.ContractID = employeeContract.ContractID; this.IdentificationNumber = employeeContract.Employee.IdentificationNumber; this.LastName = employeeContract.Employee.LastName; this.FirstName = employeeContract.Employee.FirstName; this.ContractCode = employeeContract.Contract.ContractCode; }
public static EmployeeDataTransfer ToEntity(this EmployeeContract employee) { return(new EmployeeDataTransfer { Id = employee.Id, Name = employee.Name, Department = employee.Department, HireDate = employee.HireDate, Title = employee.Title }); }
public static EmployeeViewModel ToViewModel(this EmployeeContract employee) { return(new EmployeeViewModel() { Id = employee.Id, Name = employee.Name, Department = employee.Department, HireDate = employee.HireDate, Title = employee.Title }); }
/// UC5 /// Checking whether SaveChanges() is working or not /// and returning a desired set of message public string UpdateEmployee(EmployeeContract employeeContract, int EmpId) { if (employeeRepository.UpdateEmployee(employeeContract, EmpId) == 1) { return("Employee updated successfully"); } else { return("Employee not updated"); } }
public EmployeeContract GetContract() { var contract = new EmployeeContract() { EmployeeContractID = this.EmployeeContractID, EmployeeID = this.EmployeeID, ContractID = this.ContractID }; return(contract); }
public int AddEmployee(EmployeeContract employeeContract) { EmployeeDetail emp = new EmployeeDetail() { Name = employeeContract.Name, Email = employeeContract.Email, Salary = employeeContract.Salary }; employeeManagementEntitiesObj.EmployeeDetails.Add(emp); return(employeeManagementEntitiesObj.SaveChanges()); }
public async Task <ActionResult> EmployeesToUnassign(int employeeID, int contractID) { EmployeeContract employeeContract = await employeeRepository.GetEmployeeContract(employeeID, contractID); if (employeeContract == null) { return(HttpNotFound()); } var model = new EmployeeContractViewModel(employeeContract); return(View(model)); }
public EmployeeContract GetById(int empId) { var employee = employeeManagementEntitiesObj.EmployeeDetails.Find(empId); EmployeeContract employeeContract = new EmployeeContract() { Name = employee.Name, Email = employee.Email, Salary = (int)employee.Salary, Id = employee.Id }; return(employeeContract); }
public int GetContractHours(long emplid, DateTime date) { EmployeeContract contract = IsContain(emplid, date); int result = EmployeeContract.InvalidContractHours; if (contract != null) { result = Convert.ToInt32(contract.ContractWorkingHours * 60); } return(result); }
public EmployeeContract GetById(int empId) { EmployeeContract employeeContract = employeeRepository.GetById(empId); if (employeeContract != null) { return(employeeContract); } else { return(new EmployeeContract()); } }
public string UpdateEmploye(EmployeeContract employeeContract, string EmpId) { try { return(employeeBusiness.UpdateEmployee(employeeContract, Convert.ToInt32(EmpId))); } catch (Exception e) { ErrorClass err = new ErrorClass(); err.success = false; err.message = e.Message; throw new WebFaultException <ErrorClass>(err, HttpStatusCode.NotFound); } }
public string AddEmployee(EmployeeContract employeeContract) { try { return(employeeBusiness.AddEmployee(employeeContract)); } catch (Exception e) { ErrorClass err = new ErrorClass(); err.success = false; err.message = e.Message; throw new WebFaultException <ErrorClass>(err, HttpStatusCode.NotFound); } }
public EmployeeContractDlg(EmployeeDocument document, Employee employee, IUnitOfWork uow) { this.Build(); TabName = "Новый договор"; UoW = uow; Entity = new EmployeeContract(); Entity.FirstDay = DateTime.Now; Entity.LastDay = DateTime.Now.AddYears(1); Entity.ContractDate = DateTime.Now; Entity.Document = document; Entity.Employee = employee; ConfigureDlg(); this.ShowAll(); }
private static HourlySalaryEmployee CreateHourlySalaryEmployee(EmployeeContract e) { return(new HourlySalaryEmployee() { Id = e.Id, Name = e.Name, ContractTypeName = e.ContractTypeName, RoleId = e.RoleId, RoleName = e.RoleName, RoleDescription = e.RoleDescription, HourlySalary = e.HourlySalary, MonthlySalary = e.MonthlySalary }); }
//UC3 public EmployeeContract AddEmployee(EmployeeContract employeeContract) { Emp_Payroll employee = new Emp_Payroll() { name = employeeContract.Name, email = employeeContract.Email, salary = employeeContract.Salary }; employeeManagementEntitiesObj.Emp_Payroll.Add(employee); employeeManagementEntitiesObj.SaveChanges(); employeeContract.Id = employee.id; return(employeeContract); }
public async Task <IActionResult> Edit(int id, EmployeeContract employeeContract) { if (id != employeeContract.Id) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } if (ModelState.IsValid) { var employee = await _repository.GetEmployeeContract(id); if (await _repository.IsEemployeeHasContractActive(id, employeeContract.EmployeeId) && employeeContract.Status == true) { return(RedirectToAction(nameof(Index)).WithDanger("danger", "لايمكن تعديل العقد بلحالة نشط . يوجد عقد سابق نشط ")); } try { employee.EmployeeId = employeeContract.EmployeeId; employee.FromDate = employeeContract.FromDate; employee.HourlyPay = employeeContract.HourlyPay; employee.JopId = employeeContract.JopId; employee.SeasonId = employeeContract.SeasonId; employee.ToDate = employeeContract.ToDate; employee.Status = employeeContract.Status; _repository.Update <EmployeeContract>(employee); await _repository.SavaAll(); } catch (DbUpdateConcurrencyException) { if (_repository.GetEmployeeContract(employeeContract.Id) == null) { ViewBag.ErrorMessage = "لايوجد بيانات"; return(View("NotFound")); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["JopId"] = new SelectList(await _repository.GetJops(), "Id", "Name", employeeContract.JopId); ViewData["SeasonId"] = new SelectList(await _repository.GetSeasons(), "Id", "Name", employeeContract.SeasonId); ViewData["EmployeeId"] = new SelectList(await _repository.GetEmployees(), "Id", "Name", employeeContract.EmployeeId); return(View(employeeContract)); }
public int UpdateEmployee(EmployeeContract employeeContract, int EmpId) { EmployeeDetail employee = employeeManagementEntitiesObj.EmployeeDetails.Find(EmpId); if (employee != null) { employee.Email = employeeContract.Email; employee.Name = employeeContract.Name; employee.Salary = employeeContract.Salary; return(employeeManagementEntitiesObj.SaveChanges()); } else { throw new Exception("Employee do not exists"); } }