Exemple #1
0
        public async Task <bool> UpdateCategoria(CategoriaModel update)
        {
            //throw new NotImplementedException();
            var table = TablaAzure();

            var retriveOP = TableOperation
                            .Retrieve <CategoriaAzEntity>(
                update.CategoriaCodigo.Substring(0, 3),
                update.CategoriaCodigo
                );
            var resultado = await table.ExecuteAsync(retriveOP);

            if (resultado != null)
            {
                var p = resultado.Result as CategoriaAzEntity;
                p.Descripcion = update.Descripcion;

                var upOp = TableOperation.Replace(p);
                await table.ExecuteAsync(upOp);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        public async Task <bool> CrearCategoria(CategoriaModel nuevo)
        {
            var table = TablaAzure();
            // Create the table if it doesn't exist.
            var creada = await table.CreateIfNotExistsAsync();

            var azEn = new CategoriaAzEntity(nuevo.CategoriaCodigo);

            azEn.Descripcion     = nuevo.Descripcion;
            azEn.CategoriaCodigo = nuevo.CategoriaCodigo;

            // Create the TableOperation object that inserts the customer entity.
            TableOperation insertOperation = TableOperation.Insert(azEn);

            // Execute the insert operation.
            var x = await table.ExecuteAsync(insertOperation);

            return(true);
        }