public Message AddMessage(MessageViewModel message) { var clubeId = _userServices.GetClubByUserName(_userRepository.GetById(message.UserId).Email).Id; var msg = new Message() { Image = message.Image, SendAt = DateTime.Now, Text = message.Message, UserId = message.UserId, ClubId = clubeId }; return _messageRepository.Add(msg); }
public MessageViewModel ConvertToMessageViewModel(Message message) { return new MessageViewModel() { Id = message.MessageId, Message = message.Text, SendAt = message.SendAt, UserId = message.User.Id, Image = message.Image, UserName = message.User.Role == Role.ClubAdmin ? "Club Administrator" : message.User.UserDetail.FirstName + " " + message.User.UserDetail.LastName, UserAva = string.IsNullOrEmpty(message.User.UserDetail.ProfilePicture) ? "/Images/ProfilePicture.jpg" : "/api/file/ProfilePicture/" + message.User.UserDetail.ProfilePicture + "/" + message.User.Id }; }