/// <summary> /// The mentor can update himself. /// </summary> /// <param name="updateMentorDTO"></param> /// <returns></returns> public async Task UpdateCurrentMentorAsync(UpdateMentorDTO updateMentorDTO) { var toBeUpdatedMentor = await _userManager.FindByNameAsync(_loggedUser).ConfigureAwait(false) ?? throw new MilvaUserFriendlyException("CannotFindUserWithThisToken"); toBeUpdatedMentor.ThrowIfNullForGuidObject(); toBeUpdatedMentor.Mentor.Name = updateMentorDTO.Name; toBeUpdatedMentor.Mentor.Surname = updateMentorDTO.Surname; await _mentorRepository.UpdateAsync(toBeUpdatedMentor.Mentor).ConfigureAwait(false); }
/// <summary> /// Updates single mentor which that equals <paramref name="updateMentorDTO"/> in repository by <paramref name="updateMentorDTO"/>'s properties. /// </summary> /// <param name="updateMentorDTO">Mentor to be updated.</param> /// <param name="Id">Id of the to be updated mentor.</param> /// <returns></returns> public async Task UpdateMentorByAdminAsync(UpdateMentorDTO updateMentorDTO, Guid Id) { var toBeUpdatedMentor = await _mentorRepository.GetByIdAsync(Id).ConfigureAwait(false); toBeUpdatedMentor.ThrowIfNullForGuidObject(); toBeUpdatedMentor.Name = updateMentorDTO.Name; toBeUpdatedMentor.Surname = updateMentorDTO.Surname; await _mentorRepository.UpdateAsync(toBeUpdatedMentor).ConfigureAwait(false); }
public async Task <IActionResult> UpdateMentorbyAdmin([FromBody] UpdateMentorDTO updateMentor, Guid Id) { return(await _mentorService.UpdateMentorByAdminAsync(updateMentor, Id).ConfigureAwait(false).GetObjectResponseAsync <UpdateMentorDTO>("Success"));; }
public async Task <IActionResult> UpdateCurrentMentor([FromBody] UpdateMentorDTO updateMentor) { return(await _mentorService.UpdateCurrentMentorAsync(updateMentor).ConfigureAwait(false).GetObjectResponseAsync <UpdateMentorDTO>("Success")); }