public bool AddHeadToProject(int projectId, int headId) { ProjectHead projectHead = _db.ProjectHeads.Where(pc => pc.ProjectID == projectId && pc.HeadID == headId).SingleOrDefault(); if (projectHead == null) { ProjectHead newProjectHead = new ProjectHead { ProjectID = projectId, HeadID = headId, IsActive = true }; _db.AddToProjectHeads(newProjectHead); _db.SaveChanges(); return true; } return false; }
/// <summary> /// Deprecated Method for adding a new object to the ProjectHeads EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProjectHeads(ProjectHead projectHead) { base.AddObject("ProjectHeads", projectHead); }
/// <summary> /// Create a new ProjectHead object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="projectID">Initial value of the ProjectID property.</param> /// <param name="headID">Initial value of the HeadID property.</param> /// <param name="isActive">Initial value of the IsActive property.</param> public static ProjectHead CreateProjectHead(global::System.Int32 id, global::System.Int32 projectID, global::System.Int32 headID, global::System.Boolean isActive) { ProjectHead projectHead = new ProjectHead(); projectHead.ID = id; projectHead.ProjectID = projectID; projectHead.HeadID = headID; projectHead.IsActive = isActive; return projectHead; }