public int DeleteEmp(int empid) { EmployeeEntities1 empdb = new EmployeeEntities1(); EmployeeDetail empdtl = new EmployeeDetail(); empdtl.EmpId = empid; empdb.Entry(empdtl).State = System.Data.Entity.EntityState.Deleted; int r = empdb.SaveChanges(); return(r); }
public EmployeeDetail RetreiveEmployeeByID(int id) { var employee = context.EmployeeDetails.Find(id); var result = new EmployeeDetail(); if (employee != null) { result.Id = employee.Id; result.Name = employee.Name; result.Designation = employee.Designation; } return(result); }
public List <EmployeeDetail> UpdateEmployee(EmployeeDetail employee) { var worker = context.EmployeeDetails.Find(employee.Id); if (worker != null) { worker.Name = employee.Name; worker.Designation = employee.Designation; context.SaveChanges(); } var employeesList = context.EmployeeDetails.ToList(); return(employeesList); }
public int UpdateEmp(Employee e) { EmployeeEntities1 empdb = new EmployeeEntities1(); EmployeeDetail empdtl = new EmployeeDetail(); empdtl.EmpId = e.empId; empdtl.EmpName = e.empName; empdtl.EmpMail = e.empMail; empdtl.EmpPhone = e.empPhone; empdb.Entry(empdtl).State = System.Data.Entity.EntityState.Modified; int r = empdb.SaveChanges(); return(r); }
public int AddEmp(Employee emp) { EmployeeEntities1 empdb = new EmployeeEntities1(); EmployeeDetail empdtl = new EmployeeDetail(); empdtl.EmpId = emp.empId; empdtl.EmpName = emp.empName; empdtl.EmpMail = emp.empMail; empdtl.EmpPhone = emp.empPhone; empdb.EmployeeDetails.Add(empdtl); int r = empdb.SaveChanges(); return(r); }
public EmployeeDetail GetAllUserById(int empId) { EmployeeEntities1 empdb = new EmployeeEntities1(); var emplst = from e in empdb.EmployeeDetails where e.EmpId == empId select e; EmployeeDetail employee = new EmployeeDetail(); foreach (var item in emplst) { employee.EmpId = item.EmpId; employee.EmpName = item.EmpName; employee.EmpMail = item.EmpMail; employee.EmpPhone = item.EmpPhone; } return(employee); }
public string AddEmployee(EmployeeDetail employee) { var employeesList = context.EmployeeDetails.ToList(); if (employeesList != null && employeesList.Count != 0) { employee.Id = employeesList[employeesList.Count - 1].Id + 1; } else { employee.Id = 1; } context.EmployeeDetails.Add(employee); context.SaveChanges(); return("success"); }
public List <EmployeeDetail> GetAllEmp() { List <EmployeeDetail> emplist = new List <EmployeeDetail>(); EmployeeEntities1 empdb = new EmployeeEntities1(); var emplst = from e in empdb.EmployeeDetails select e; foreach (var item in emplst) { EmployeeDetail em = new EmployeeDetail(); em.EmpId = item.EmpId; em.EmpName = item.EmpName; em.EmpMail = item.EmpMail; em.EmpPhone = item.EmpPhone; emplist.Add(em); } return(emplist); }