Esempio n. 1
0
 public Employee GetEmployeeByEmployeeID(int EmpID)
 {
     using (companyEntities db = new companyEntities())
     {
         Employee emp = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();
         return(emp);
     }
 }
Esempio n. 2
0
 public List <Employee> GetEmployees()
 {
     using (companyEntities db = new companyEntities())
     {
         List <Employee> emps = db.Employees.ToList();
         return(emps);
     }
 }
Esempio n. 3
0
        public (bool, Guid) InsertEmployee(Employee emp)
        {
            using (companyEntities db = new companyEntities())
            {
                emp.EmpID = Guid.NewGuid();
                //db.Employees.Add(emp);
                //db.SaveChanges();
                int n = db.InsertEmployee(emp.EmpID, emp.EmpName, emp.Salary);
            }

            return(true, emp.EmpID);
        }
Esempio n. 4
0
        public bool DeleteEmployee(Employee emp)
        {
            using (companyEntities db = new companyEntities())
            {
                Employee existingEmployee = db.Employees.Where(temp => temp.EmpID == emp.EmpID).FirstOrDefault();

                if (existingEmployee == null)
                {
                    return(false);
                }
                else
                {
                    db.Employees.Remove(existingEmployee);
                    db.SaveChanges();
                    return(true);
                }
            }
        }
Esempio n. 5
0
        public bool UpdateEmployee(Employee emp)
        {
            using (companyEntities db = new companyEntities())
            {
                Employee existingEmployee = db.Employees.Where(temp => temp.EmpID == emp.EmpID).FirstOrDefault();

                if (existingEmployee == null)
                {
                    return(false);
                }
                else
                {
                    existingEmployee.EmpName = emp.EmpName;
                    existingEmployee.Salary  = emp.Salary;
                    db.SaveChanges();
                    return(true);
                }
            }
        }