public async Task <ActionResult <DtoLigacao> > GetByHumanCode(DtoLigacao dto)
        {
            try
            {
                var myUsername = User.Identity.Name;
                if (ZZApiMain.VerifyUserAuthorize(myUsername))
                {
                    if (ZZApiMain.UsersConnections.TryGetValue(myUsername, out var myConn))
                    {
                        var myId = await myConn.Zz.ApiWriteServer(myUsername, new Command { Cmd = ServerCommands.GetById, EntityId = dto.Id, Tela = Tela, Json = await SerializerAsync.SerializeJson(dto) });

                        var responseCommand = await myConn.Zz.GetApiWaitCommand(myId);

                        if (responseCommand != null && responseCommand.Cmd.Equals(ServerCommands.LogResultOk))
                        {
                            return(await SerializerAsync.DeserializeJson <DtoLigacao>(responseCommand.Json));
                        }
                    }
                }
                return(NotFound());
            }
            catch (Exception e)
            {
                ConsoleEx.WriteError(e);
                return(NotFound());
            }
        }
Exemple #2
0
        public override EntityDto ConvertDto()
        {
            try
            {
                var dto = new DtoLigacao
                {
                    Id          = Id, Codigo = Codigo, FirstDtoId = FuncionarioId, FirstDto = Funcionario.ConvertDto(),
                    SecondDtoId = EstoqueId, SecondDto = Estoque.ConvertDto()
                };

                return(dto);
            }
            catch (Exception e)
            {
                ConsoleEx.WriteError(e);
                return(null);
            }
        }