public IHttpActionResult PostWorkAllocation(WorkAllocation workAllocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.WorkAllocations.Add(workAllocation); try { db.SaveChanges(); } catch (DbUpdateException) { if (WorkAllocationExists(workAllocation.TeamID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = workAllocation.TeamID }, workAllocation)); }
public IHttpActionResult PutWorkAllocation(int id, WorkAllocation workAllocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != workAllocation.TeamID) { return(BadRequest()); } db.Entry(workAllocation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!WorkAllocationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetWorkAllocation(int workId, int userId) { WorkAllocation workAllocation = db.WorkAllocations.Find(workId, userId); if (workAllocation == null) { return(NotFound()); } return(Ok(workAllocation)); }
public async Task <bool> AddWork(WorkAllocation _work) { ResponseMessage = await client.PostAsJsonAsync("Work/AddWork", _work); if (ResponseMessage.IsSuccessStatusCode) { return(true); } else { return(false); } }
public IHttpActionResult DeleteWorkAllocation(int id, int team) { WorkAllocation workAllocation = db.WorkAllocations.Find(id); if (workAllocation == null) { return(NotFound()); } db.WorkAllocations.Remove(workAllocation); db.SaveChanges(); return(Ok(workAllocation)); }