public static bool Create(Employee employee) { bool result = true; try { db.Employees.AddObject(employee); db.SaveChanges(); } catch (Exception) { result = false; } return result; }
public static bool Update(Employee employee) { bool result = true; try { EntityDataModelContainer mc = new EntityDataModelContainer(); mc.Employees.Attach(employee); mc.ObjectStateManager.ChangeObjectState(employee, EntityState.Modified); mc.SaveChanges(); db.Refresh(System.Data.Objects.RefreshMode.StoreWins, employee); } catch (Exception) { result = false; } return result; }
/// <summary> /// Create a new Employee object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="fIO">Initial value of the FIO property.</param> /// <param name="phone">Initial value of the Phone property.</param> /// <param name="email">Initial value of the Email property.</param> public static Employee CreateEmployee(global::System.Int32 id, global::System.String fIO, global::System.String phone, global::System.String email) { Employee employee = new Employee(); employee.Id = id; employee.FIO = fIO; employee.Phone = phone; employee.Email = email; return employee; }
/// <summary> /// Deprecated Method for adding a new object to the Employees EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToEmployees(Employee employee) { base.AddObject("Employees", employee); }