public IHttpActionResult Postproject_costs(project_costs project_costs) { Queries q = new Queries(); project_costs.project_pid = projectsController.CurrentProjectId; project_costs.employee_eid = q.GetUserId(); project_costs.costtimestamp = DateTime.Now; if (!ModelState.IsValid) { return BadRequest(ModelState); } db.project_costs.Add(project_costs); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = project_costs.pcid }, project_costs); }
public IHttpActionResult Putproject_costs(int id, project_costs project_costs) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != project_costs.pcid) { return BadRequest(); } db.Entry(project_costs).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!project_costsExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }