public async Task <ActionResult <bool> > Edit(TipoEntradaDto 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 { Tela = Tela, Cmd = ServerCommands.Edit, EntityId = dto.Id, Json = await SerializerAsync.SerializeJson(dto) });

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

                        if (responseCommand != null && responseCommand.Cmd.Equals(ServerCommands.LogResultOk))
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }
            catch (Exception e)
            {
                ConsoleEx.WriteError(e);
                return(NotFound());
            }
        }
        public async Task <IActionResult> Edit(TipoEntradaViewModel vm)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Error de validacion no controlado");
                }

                var tipoEntradaDto = new TipoEntradaDto()
                {
                    Id                 = vm.Id,
                    Nombre             = vm.Nombre,
                    EmpresaId          = vm.EmpresaId,
                    BeneficioEntradaId = vm.BeneficioEntradaId
                };

                await _tipoEntradaServicio.Modificar(tipoEntradaDto);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception)
            {
                return(View(vm));
            }
        }
示例#3
0
        public override EntityDto ConvertDto()
        {
            try
            {
                var dto = new TipoEntradaDto { Id = Id, Description = Descricao, Codigo = Codigo,
                    NomeEntity = NomeEntity, ControlaEstoque = ControlaEstoque};

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