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); } }
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); } }
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); } }
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); } }
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); } }