public async Task <bool> AddSuperVisorToProject(string projectId, MongoSuperVisor superVisor) { var oldProject = await GetProjectById(projectId); superVisor.Id = Guid.NewGuid().ToString(); oldProject.SuperVisior = superVisor; var result = await _Projects.ReplaceOneAsync(project => project.Id == projectId, oldProject); return(result.IsAcknowledged); }
public async Task <IActionResult> AddSuperVisorToProject([FromRoute] string projectId, [FromForm] CreateSuperVisorViewModel model) { if (ModelState.IsValid) { var superVisor = new MongoSuperVisor { Name = model.SuperVisorName }; var result = await _mongoProjectService.AddSuperVisorToProject(projectId, superVisor); if (result) { return(Ok(new { status = 1, message = "Add successfully" })); } return(BadRequest(new { status = 0, message = "Not Added" })); } return(BadRequest(new { status = 0, message = "Not Valid" })); }