public async Task UpdateTeam(UpdateTeamRequestModel requestModel) { Employee employee = await GetById(requestModel.Id); employee.BossId = requestModel.BossId; _context.Update(employee); await _context.SaveChangesAsync(); }
public async Task <ActionResult> Update(int projectId, int teamId, [FromBody] UpdateTeamRequestModel input) { var updateRequest = await this.teamService.UpdateAsync( teamId, input.Title, input.ImageUrl, projectId); if (!updateRequest.Success) { return(this.BadRequest(new ErrorsResponseModel { Errors = updateRequest.Errors, })); } return(this.Ok()); }
public async Task <IActionResult> UpdateTeamMember([FromBody] UpdateTeamRequestModel teamRequestModel) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var employee = await _teamRepository.GetById(teamRequestModel.Id); if (employee == null) { return(BadRequest("Employee does not exist")); } var boss = await _teamRepository.GetById(teamRequestModel.BossId); if (boss == null) { return(BadRequest("Given new boss does not exist")); } await _teamRepository.UpdateTeam(teamRequestModel); return(Ok()); } catch (DbUpdateConcurrencyException e) { return(BadRequest(e.Message)); } catch (Exception e) { return(BadRequest(e.Message)); } }