public async Task <ActionResult <EmployeeDocument> > Edit(int companyId, int projectId, [FromBody] ProjectDocument project) { if (projectId != project.Id) { return(BadRequest()); } var employeeDto = await CompanyService.GetByIdAsync(companyId); if (employeeDto == null) { return(NotFound($"Employee with id: '{companyId}' not found")); } var projectDto = await ProjectService.GetByIdAsync(projectId); if (projectDto == null) { return(NotFound($"Project with id: '{projectId}' not found")); } await ProjectService.EditAsync(companyId, project.ToDto()); return(NoContent()); }
public async Task <ActionResult> Create(int companyId, [FromBody] ProjectDocument project) { var companyDto = await CompanyService.GetByIdAsync(companyId); if (companyDto == null) { return(NotFound($"Company with id: '{companyId}' not found")); } var createdProject = await ProjectService.CreateAsync(companyId, project.ToDto()); return(CreatedAtAction(nameof(GetById), new { id = createdProject.Id }, createdProject.ToDocument())); }