예제 #1
0
        public MessageBoardForCreateDto AddMessageBoardEntry(MessageBoardForCreateDto message)
        {
            try
            {
                Console.WriteLine("Inside AddMessageBoardEntry() ");

                var messageboardentry = AutoMapper.Mapper.Map <Entities.MessageBoard>(message);

                _messagesRepository.AddMessageBoardEntry(messageboardentry);

                if (!_messagesRepository.Save())
                {
                    throw new Exception("Error occurred during AddMessageBoardEntry() of User ...");
                }

                return(message);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error in AddMessageBoardEntry() {e.Message}");
                _logger.LogError($"Error in AddMessageBoardEntry() {e.Message}");

                return(null);
            }
        }
예제 #2
0
        public IActionResult CreateMessageBoardEntry([FromBody] MessageBoardForCreateDto msgboardcreate)
        {
            try
            {
                Console.WriteLine("Entered CreateMessageBoardEntry() ");

                var resp = _messageboardService.AddMessageBoardEntry(msgboardcreate);

                return(Ok(resp));
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error in CreateMessageBoardEntry { e.Message }");
                _logger.LogError($"Error in CreateMessageBoardEntry { e.Message }");

                return(StatusCode(500, e.Message));
            }
        }