コード例 #1
0
        // 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);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
        public async Task <bool> EmployeeContractAlreadyExists(string contractCode)
        {
            EmployeeContract contract = await ApplicationDbContext.Set <EmployeeContract>()
                                        .FindAsync(contractCode);

            return(contract != null);
        }
コード例 #6
0
 public UnbreakContract(EmployeeContract contract)
 {
     BeginDate = contract.ContractBegin;
     EndDate   = contract.ContractEnd;
     _Contracts.Add(contract);
     NextContract = null;
 }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        private async Task DoWork(CancellationToken stoppingToken)
        {
            using IServiceScope scope = ServiceProvider.CreateScope();
            EmployeeContract employeeContractProcessingService =
                scope.ServiceProvider.GetRequiredService <EmployeeContract>();

            await employeeContractProcessingService.DoWork(stoppingToken);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 public static Employee ToEntity(this EmployeeContract employee)
 {
     return(new Employee
     {
         Id = employee.Id,
         Name = employee.Name,
         City = employee.City
     });
 }
コード例 #11
0
 public EmployeeContractDlg(int id, IUnitOfWork uow)
 {
     this.Build();
     UoW     = uow;
     Entity  = (EmployeeContract)UoW.GetById(typeof(EmployeeContract), id);
     TabName = Entity.Name + "договор";
     ConfigureDlg();
     this.ShowAll();
 }
コード例 #12
0
        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 + ")";
        }
コード例 #13
0
 public bool AddNewContractToEmployee(Employee e, EmployeeContract c)
 {
     if (GetEmployee(e.EmployeeNumber) != null)
     {
         e.employmentInfo.AddNewContract(c);
         dbman.InsertNewContractToDB(c);
         return(true);
     }
     return(false);
 }
コード例 #14
0
 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;
 }
コード例 #15
0
 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
     });
 }
コード例 #16
0
 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
     });
 }
コード例 #17
0
 /// 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");
     }
 }
コード例 #18
0
        public EmployeeContract GetContract()
        {
            var contract = new EmployeeContract()
            {
                EmployeeContractID = this.EmployeeContractID,
                EmployeeID         = this.EmployeeID,
                ContractID         = this.ContractID
            };

            return(contract);
        }
コード例 #19
0
        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());
        }
コード例 #20
0
        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));
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        public EmployeeContract GetById(int empId)
        {
            EmployeeContract employeeContract = employeeRepository.GetById(empId);

            if (employeeContract != null)
            {
                return(employeeContract);
            }
            else
            {
                return(new EmployeeContract());
            }
        }
コード例 #24
0
 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);
     }
 }
コード例 #25
0
 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);
     }
 }
コード例 #26
0
 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();
 }
コード例 #27
0
 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
     });
 }
コード例 #28
0
        //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);
        }
コード例 #29
0
        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));
        }
コード例 #30
0
        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");
            }
        }