// POST: odata/EmployeesForAttendances public async Task <IHttpActionResult> Post(EmployeesForAttendance employeesForAttendance) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.EmployeesForAttendances.Add(employeesForAttendance); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (EmployeesForAttendanceExists(employeesForAttendance.EmployeeName)) { return(Conflict()); } else { throw; } } return(Created(employeesForAttendance)); }
// DELETE: odata/EmployeesForAttendances(5) public async Task <IHttpActionResult> Delete([FromODataUri] string key) { EmployeesForAttendance employeesForAttendance = await db.EmployeesForAttendances.FindAsync(key); if (employeesForAttendance == null) { return(NotFound()); } db.EmployeesForAttendances.Remove(employeesForAttendance); await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
// PUT: odata/EmployeesForAttendances(5) public async Task <IHttpActionResult> Put([FromODataUri] string key, Delta <EmployeesForAttendance> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } EmployeesForAttendance employeesForAttendance = await db.EmployeesForAttendances.FindAsync(key); if (employeesForAttendance == null) { return(NotFound()); } patch.Put(employeesForAttendance); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeesForAttendanceExists(key)) { return(NotFound()); } else { throw; } } return(Updated(employeesForAttendance)); }