public IHttpActionResult UpdateProject(Project project) { try { Project updateProject = new Project(); updateProject.EndDate = project.EndDate; updateProject.StartDate = project.StartDate; updateProject.ProjectName = project.ProjectName; updateProject.Priority = project.Priority; updateProject.ProjectID = Convert.ToInt32(project.ProjectID); db.Entry(updateProject).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); if (project.managerId != null) { User olduser = db.Users.Where(x => x.ProjectID == project.ProjectID).FirstOrDefault(); if (olduser != null) { olduser.ProjectID = null; } User UserData = db.Users.Where(x => x.UserID == project.managerId).FirstOrDefault(); UserData.ProjectID = updateProject.ProjectID; db.SaveChanges(); } } catch (DbUpdateConcurrencyException ex) { throw; } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult UpdateTask([FromBody] Task task) { db.Entry(task).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { throw; } return(StatusCode(HttpStatusCode.NoContent)); }