Exemple #1
0
        public IActionResult GetMessages([FromRoute] String eventId, [FromHeader(Name = "Authorization")] string token)
        {
            ObjectId               reqUserId   = new ObjectId(JwtUtil.GetUserIdFromToken(token));
            List <MessageModel>    messages    = MongoUtil.GetMessages(new ObjectId(eventId));
            List <MessageApiModel> apiMessages = messages.ConvertAll(new Converter <MessageModel, MessageApiModel>(msg => {
                ObjectId pubUserId = msg.UserId;
                if (pubUserId == reqUserId)
                {
                    return(msg.getMessageApiModel());
                }
                msg.DateSent = msg.DateSent.AddHours(3);
                return(msg.getMessageApiModel(MongoUtil.GetUser(pubUserId).Name));
            }));

            return(Ok(apiMessages));
        }