public async Task<IHttpActionResult> PostProjectQuality(project_qualities model, int projectId) { if (!ModelState.IsValid) return BadRequest(); bool updated = _repo.UpdateProjectQuality(model, projectId); if (updated == true) return Ok(); model.Project_FK = projectId; db.project_qualities.Add(model); await db.SaveChangesAsync(); return Ok(); }
public bool UpdateProjectQuality(project_qualities model, int projectId) { var query = (from m in db.project_qualities where m.Project_FK == projectId select m).AsQueryable(); if (query.Count() == 0) return false; project_qualities newDescription = query.First<project_qualities>(); newDescription.content = model.content; db.Entry(newDescription).State = EntityState.Modified; db.SaveChanges(); return true; }