public async Task <IActionResult> ForwardMessageAsync(ForwardMsgDto forwardMsgDto) { var id = _userService.GetUSerIDFromUserClaims(User.Claims); if (await _messageServices.ForwardMessageAsync(forwardMsgDto, id)) { return(Ok("پیام ارجاع داده شد")); } return(BadRequest("خطایی رخ داده است")); }
public async Task <bool> ForwardMessageAsync(ForwardMsgDto forwardMsgDto, Guid userID) { var reSendOn = await _messageRecieverRepository .GetAsync(forwardMsgDto.MessageRecieverId); var messageRecievers = new List <MessageReciever>(); var messageSender = new MessageSender { IsSent = true, ResendOnId = forwardMsgDto.MessageRecieverId, MessageId = reSendOn.MessageId, Id = Guid.NewGuid(), UserId = userID, Prove = forwardMsgDto.Prove, }; foreach (var item in forwardMsgDto.ToIds) { messageRecievers.Add(new MessageReciever { Id = Guid.NewGuid(), IsCc = false, MessageId = reSendOn.MessageId, MessageSenderId = messageSender.Id, UserId = item, }); } var messageSenderResult = await _messageSenderRepository .AddAsync(messageSender); var messageRcieversResult = await _messageRecieverRepository .AddRangeAsync(messageRecievers); await _unitOfWork.SaveAsync(); return(true); }