Exemplo n.º 1
0
        public async Task <ActionResult <ProtocolDto> > CreateProtocol(ProtocolDto protocolDto)
        {
            var username = User.GetUsername();

            var protocol = new Protocol
            {
                CreatorUsername = username,
                CreatorId       = User.GetUserId(),
                ProtocolName    = protocolDto.ProtocolName
            };

            _protocolRepository.AddProtocol(protocol);

            if (await _protocolRepository.SaveAllAsync())
            {
                return(Ok(_mapper.Map <ProtocolDto>(protocol)));
            }

            return(BadRequest("Failed to create protocol"));
        }