/// <summary> /// Update Employee Information /// </summary> /// <param name="Emp"></param> /// <returns></returns> public string Update_Employee(Employee Emp) { if (Emp != null) { using (AngularCRUDEmployee Obj = new AngularCRUDEmployee()) { var Emp_ = Obj.Entry(Emp); Employee EmpObj = Obj.Employees.Where(x => x.Emp_Id == Emp.Emp_Id).FirstOrDefault(); EmpObj.Emp_Age = Emp.Emp_Age; EmpObj.Emp_City = Emp.Emp_City; EmpObj.Emp_Name = Emp.Emp_Name; Obj.SaveChanges(); return("Employee Updated Successfully"); } } else { return("Employee Not Updated! Try Again"); } }
/// <summary> /// Delete Employee Information /// </summary> /// <param name="Emp"></param> /// <returns></returns> public string Delete_Employee(Employee Emp) { if (Emp != null) { using (AngularCRUDEmployee Obj = new AngularCRUDEmployee()) { var Emp_ = Obj.Entry(Emp); if (Emp_.State == System.Data.Entity.EntityState.Detached) { Obj.Employees.Attach(Emp); Obj.Employees.Remove(Emp); } Obj.SaveChanges(); return("Employee Deleted Successfully"); } } else { return("Employee Not Deleted! Try Again"); } }