Example #1
0
        public async Task <IActionResult> AddMessage([FromRoute] int repId, [FromRoute] string content)
        {
            var state = await _service.AddAMessageAsync(content, repId);

            if (!state.Success)
            {
                return(BadRequest(state.Error));
            }

            return(Ok(new MessageDto
            {
                Id = state.Source.Id,
                DateTime = state.Source.DateTime,
                Content = state.Source.Content.Content,
                Read = state.Source.Read,
                Type = NotificationTypesEnum.Message.ToString(),
                Receivers = new List <int> {
                    repId
                }
            }));
        }