public EntityEmployee Get(int Id)
        {
            var data = base.DataContext.Employee.Where(p => p.PK_EmployeeID == Id);

            if (data.Count() == 1)
            {
                return(FactoryEmployee.Get(data.Single()));
            }
            else
            {
                return(null);
            }
        }
        public EntityEmployee GetByUserID(int UserID, int ModuleID)
        {
            var data = base.DataContext.Employee.Where(p => p.FK_UserID == UserID && p.FK_ModuleID == ModuleID);

            if (data.Count() == 1)
            {
                return(FactoryEmployee.Get(data.Single()));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        public static Employee GetEmployeeById(int id)
        {
            try
            {
                using (SqlConnection connection = GetConnection())
                {
                    SqlCommand command = new SqlCommand("spGetEmployeeById", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Clear();
                    command.Parameters.Add(new SqlParameter("@Id", id));

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        Employee employee = null;
                        if (reader.Read())
                        {
                            EmployeeType employeeType = (EmployeeType)Convert.ToInt32(reader["EmployeeType"]);
                            employee              = FactoryEmployee.Create(employeeType);
                            employee.Id           = Convert.ToInt32(reader["Id"]);
                            employee.Name         = reader["Name"].ToString();
                            employee.Gender       = reader["Gender"].ToString();
                            employee.DateOfBirth  = Convert.ToDateTime(reader["DateOfBirth"]);
                            employee.EmployeeType = employeeType;

                            if (employee.EmployeeType == EmployeeType.FullTimeEmployee)
                            {
                                ((FullTimeEmployee)employee).AnnualySalary = Convert.ToInt32(reader["AnnualySalary"]);
                            }
                            else if (employee.EmployeeType == EmployeeType.PartTimeEmployee)
                            {
                                ((PartTimeEmployee)employee).HourlyPay   = Convert.ToInt32(reader["HourlyPay"]);
                                ((PartTimeEmployee)employee).HoursWorked = Convert.ToInt32(reader["HoursWorked"]);
                            }
                        }
                        return(employee);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #4
0
        public List <Employee> Get(int id)
        {
            try
            {
                ServiceRepository   serviceObj = new ServiceRepository();
                HttpResponseMessage response   = serviceObj.GetResponse("Employees");
                response.EnsureSuccessStatusCode();

                List <Employee> employees = response.Content.ReadAsAsync <List <Employee> >().Result;
                Employee        employee  = employees.Find(x => x.Id == id);
                employee.CalculatedAnnualSalary = FactoryEmployee.CalculateAnnualSalary(employee.ContractTypeName, employee.HourlySalary, employee.MonthlySalary);
                List <Employee> result = new List <Employee>
                {
                    employee
                };

                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error {0}", e.GetType());
                throw;
            }
        }
예제 #5
0
        public List <Employee> Get()
        {
            //api/employees
            try
            {
                ServiceRepository   serviceObj = new ServiceRepository();
                HttpResponseMessage response   = serviceObj.GetResponse("Employees");
                response.EnsureSuccessStatusCode();

                List <Employee> employees = response.Content.ReadAsAsync <List <Employee> >().Result;

                foreach (var employee in employees)
                {
                    employee.CalculatedAnnualSalary = FactoryEmployee.CalculateAnnualSalary(employee.ContractTypeName, employee.HourlySalary, employee.MonthlySalary);
                }

                return(employees);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error {0}", e.GetType());
                throw;
            }
        }
 public List <EntityEmployee> GetAll()
 {
     return(FactoryEmployee.GetList(base.DataContext.Employee.ToList()));
 }
 public List <EntityEmployee> GetActives()
 {
     return(FactoryEmployee.GetList(base.DataContext.Employee.Where(p => p.Status == true).ToList()));
 }
 public List <EntityEmployee> GetEByUserID(int UserID)
 {
     return(FactoryEmployee.GetList(base.DataContext.Employee.Where(p => p.FK_UserID == UserID).ToList()));
 }