Exemple #1
0
 public Chat Create([FromBody] Chat chat)
 {
     try
     {
         var createdChat = _chatsRepository.CreateChat(chat);
         _logger.Info($"Chat with Id: {chat.Id} has been added");
         return(createdChat);
     }
     catch (ArgumentException ex)
     {
         _logger.Error($"{DateTime.Now.ToShortDateString()} Chat with Id: {chat.Id} has NOT been added because of {ex.Message}");
     }
     return(null);
 }
Exemple #2
0
 public Chat CreateChat([FromBody] Chat chat)
 {
     try
     {
         return(_chatsRepository.CreateChat(chat));
     }
     catch (SqlException exception)
     {
         var response = new HttpResponseMessage(HttpStatusCode.NotFound)
         {
             Content = new StringContent(exception.Message)
         };
         throw new HttpResponseException(response);
     }
 }