Ejemplo n.º 1
0
        public async Task <Administrador> GetAdministrador(string partitionKey)
        {
            string        rowKey        = GetRowKeyByPartitionKey(partitionKey).Result;
            Administrador administrador = new Administrador(); if (string.IsNullOrEmpty(rowKey))
            {
                return(administrador);
            }
            TableOperation RetrieveOperation = TableOperation.Retrieve <AdministradorEntity>(partitionKey, rowKey);
            TableResult    RetrievedResult   = await cloudTableAD.ExecuteAsync(RetrieveOperation);

            AdministradorEntity EntityToRead = (AdministradorEntity)RetrievedResult.Result;

            administrador.email    = EntityToRead.PartitionKey; administrador.username = EntityToRead.RowKey;
            administrador.password = EntityToRead.password; return(administrador);
        }
Ejemplo n.º 2
0
        public async Task <bool> CrearAdministrador(Administrador administrador)
        {
            bool response = false;

            try {
                AdministradorEntity administradorEntity = new AdministradorEntity(administrador.email, administrador.username);
                administradorEntity.password = EncryptPassword(administrador.password);
                TableOperation insertOperation = TableOperation.Insert(administradorEntity);
                await cloudTableAD.ExecuteAsync(insertOperation); response = true;
            }
            catch (Exception exception) {
                Console.ForegroundColor = ConsoleColor.Red;
                await Console.Out.WriteLineAsync(exception.Message);

                Console.ForegroundColor = ConsoleColor.Green;
                response = false;
            }
            return(response);
        }