Пример #1
0
 public int DeleteUserById(int Id)
 {
     using (WCFServiceEntities tstDb = new WCFServiceEntities())
     {
         Employee usrdtl = new Employee();
         usrdtl.EmployeeID         = Id;
         tstDb.Entry(usrdtl).State = EntityState.Deleted;
         int Retval = tstDb.SaveChanges();
         return(Retval);
     }
 }
Пример #2
0
        public int UpdateUser(Employee objEmployee)
        {
            using (WCFServiceEntities tstDb = new WCFServiceEntities())
            {
                Employee usrdtl = new Employee();
                usrdtl.EmployeeID         = objEmployee.EmployeeID;
                usrdtl.FirstName          = objEmployee.FirstName;
                usrdtl.LastName           = objEmployee.LastName;
                usrdtl.Position           = objEmployee.Position;
                usrdtl.Office             = objEmployee.Office;
                tstDb.Entry(usrdtl).State = EntityState.Modified;

                int Retval = tstDb.SaveChanges();
                return(Retval);
            }
        }
Пример #3
0
 public int AddUser(Employee objEmployee)
 {
     using (WCFServiceEntities tstDb = new WCFServiceEntities())
     {
         Employee usrdtl = new Employee();
         usrdtl.EmployeeID = objEmployee.EmployeeID;
         usrdtl.FirstName  = objEmployee.FirstName;
         usrdtl.LastName   = objEmployee.LastName;
         usrdtl.EmpCode    = objEmployee.EmpCode;
         usrdtl.Position   = objEmployee.Position;
         usrdtl.Office     = objEmployee.Office;
         tstDb.Employees.Add(usrdtl);
         int Retval = tstDb.SaveChanges();
         return(Retval);
     }
 }
Пример #4
0
 public Employee GetAllUserById(int id)
 {
     using (WCFServiceEntities tstDb = new WCFServiceEntities())
     {
         var      lstUsr = from k in tstDb.Employees where k.EmployeeID == id select k;
         Employee usr    = new Employee();
         foreach (var item in lstUsr)
         {
             usr.EmployeeID = item.EmployeeID;
             usr.FirstName  = item.FirstName;
             usr.LastName   = item.LastName;
             usr.Position   = item.Position;
             usr.Office     = item.Office;
         }
         return(usr);
     }
 }
Пример #5
0
        public List <Employee> GetAllUser()
        {
            List <Employee> userlst = new List <Employee>();

            using (WCFServiceEntities tstDb = new WCFServiceEntities())
            {
                var lstUsr = from k in tstDb.Employees select k;
                foreach (var item in lstUsr)
                {
                    Employee usr = new Employee();
                    usr.EmployeeID = item.EmployeeID;
                    usr.FirstName  = item.FirstName;
                    usr.LastName   = item.LastName;
                    usr.EmpCode    = item.EmpCode;
                    usr.Position   = item.Position;
                    usr.Office     = item.Office;
                    userlst.Add(usr);
                }
                return(userlst);
            }
        }