public int addEmployeeToGroup(int EmpId, int GroupId) { db.Configuration.ProxyCreationEnabled = false; GroupEmployee ge = new GroupEmployee(); ge.EmpId = EmpId; ge.GroupId = GroupId; db.GroupEmployees.Add(ge); return db.SaveChanges(); }
public IHttpActionResult PutGroupEmployee(int id, GroupEmployee groupEmployee) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != groupEmployee.Id) { return BadRequest(); } db.Entry(groupEmployee).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GroupEmployeeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostGroupEmployee(GroupEmployee groupEmployee) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.GroupEmployees.Add(groupEmployee); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = groupEmployee.Id }, groupEmployee); }