public async Task <IActionResult> CreateKudoByUserNameAsync(KudoDto kudo) { try { kudo.SenderUsername = User.FindFirst(KudoConstants.UserInfo.USERNAME)?.Value; await _kudoService.CreateKudoByUserNameAsync(kudo); return(Ok()); } catch (BussinessException ex) { return(StatusCode(StatusCodes.Status500InternalServerError, $"Internal server error: {ex.Message}")); } }
/// <summary> /// create kudo with username /// </summary> /// <param name="kudo"></param> /// <returns></returns> public async Task CreateKudoByUserNameAsync(KudoDto kudo) { var sender = _employeeRepository.GetEmployeeByUserName(kudo.SenderUsername); var reciver = _employeeRepository.GetEmployeeByUserName(kudo.ReceiverUsername); if (sender != null && reciver != null) { var newKudo = new Kudo { SenderId = sender.Id, ReceiverId = reciver.Id, KudoDetail = new KudoDetail { Content = kudo.Content, SlackEmoji = kudo.SlackEmoji, KudoTypeId = kudo.KudoTypeId } }; await _kudoRepository.InsertAsync(newKudo); } }