Esempio n. 1
0
 public static List <Employee> GetAllEmployees()
 {
     using (Entities2 db = new Entities2())
     {
         return(db.Employee.ToList());
     }
 }
Esempio n. 2
0
 public static void AddEmployee(Employee e)
 {
     using (Entities2 db = new Entities2())
     {
         db.Employee.Add(e);
         db.SaveChanges();
     }
 }
Esempio n. 3
0
 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();
         }
     }
 }
Esempio n. 4
0
 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();
         }
     }
 }
Esempio n. 5
0
        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");
                }
            }
        }