public static List <Employee> GetAllEmployees() { using (Entities2 db = new Entities2()) { return(db.Employee.ToList()); } }
public static void AddEmployee(Employee e) { using (Entities2 db = new Entities2()) { db.Employee.Add(e); db.SaveChanges(); } }
public static void UpdatEmployee(int id, Employee e) { using (Entities2 db = new Entities2()) { Employee em = db.Employee.Find(id); if (em != null) { em.IdPosition = e.IdPosition; em.LastNameEmployee = e.LastNameEmployee; em.FirstNameEmployee = e.FirstNameEmployee; em.IdPosition = e.IdPosition; em.StatusEmployee = e.StatusEmployee; db.SaveChanges(); } } }
public static void DeleteEmployee(int IdEmployee) { using (Entities2 db = new Entities2()) { Employee e = db.Employee.Find(IdEmployee); try { db.Employee.Remove(e); db.SaveChanges(); } catch (Exception) { e.StatusEmployee = false; db.SaveChanges(); } } }
public static string FindUser(User u) { using (Entities2 db = new Entities2()) { User e = db.User.FirstOrDefault(o => o.UserName == u.UserName && o.Password == u.Password); if (e != null) { Employee em = db.Employee.FirstOrDefault(o => o.UserId == e.UserId); if (em != null) { return("employee"); } return("interested"); } else { return("notfound"); } } }