Пример #1
0
        public async Task <IActionResult> AddContact([FromBody] AddContactDTO AddContactDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { message = ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage) }));
            }

            var createMessage = _mapper.Map <Message>(AddContactDto);

            try
            {
                var createdMessage = await _chatService.AddContact(createMessage);

                return(Ok(createdMessage));
            }
            catch (ProjectNotFound)
            {
                return(NotFound(new MessageObj("Project not found")));
            }
            catch (EnvironmentNotSet)
            {
                throw;
            }
            catch (Exception e)
            {
                return(BadRequest(new MessageObj(e.Message)));
            }
        }
Пример #2
0
 public async Task <IActionResult> AddContact([FromBody] ContactVm contactVm) =>
 Ok(await _chatService.AddContact(contactVm));