public bool Save(EmployeeModel em, out string msg) { try { using (masterDBEntities obj = new masterDBEntities()) { var temp = obj.Employee.Find(em.EmployeeId); Employee emp = temp == null ? new Employee() : temp; emp.Name = em.Name; emp.Email = em.Email; emp.Designation = em.Designation; emp.Salary = em.Salary; emp.DateOfJoining = em.DateOfJoining; emp.Status = em.Status; if (temp == null) { obj.Employee.Add(emp); msg = "Saved Successfully"; } else { msg = "Updated Successfully"; } obj.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }
public bool Delete(Int64?id) { try { using (masterDBEntities obj = new masterDBEntities()) { var v = obj.Employee.Find(id); if (v == null) { return(false); } obj.Employee.Remove(v); obj.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }