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