コード例 #1
0
        /// <summary>
        /// Aplica reglas de negocio a la lista de origen e intenta guardar la informacion faltante en la base de datos
        /// Solo incorpora libros que NO EXISTEN
        /// </summary>
        /// <param name="lista"></param>
        public void ExportarListaDeLibros(IEnumerable <Libro> lista)
        {
            //  ver si el libro ya existe...(por ISBN13)
            //  si el ISBN es null lo agrego sin mas...
            //  si no existe lo agrego

            foreach (Libro libro in lista)
            {
                //if (!_ctx.Libros.Any(lib => lib.ISBN13 == libro.ISBN13))
                if (!_ctx.Set <Libro>().Any(lib => lib.ISBN13 == libro.ISBN13))
                {
                    //  podriamos setear la PK desde nuestra aplicacion!
                    //
                    //  nuevo.ID_Real = Guid.NewGuid();
                    //
                    _ctx.Add <Libro>(libro);
                    //  _ctx.Libros.Add(libro);
                }
                else
                {
                    _logger.LogWarning("Se intento ingresar un elemento existente {libro}", libro);
                }
            }
            //  guardamos la operacion TOTAL
            //
            _ctx.SaveChanges();
        }
コード例 #2
0
        public void Process()
        {
            using(SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(@"D:\product.xlsx", SpreadsheetDocumentType.Workbook))
            {
                var excelExportContext = new ExportContext(spreadsheetDocument);

                uint rowNo = 0;
                foreach(var product in _products)
                {
                    rowNo++;
                    if(product.Price > 44)
                    {
                        product.MapColumn<Product>(x => x.Description, "F");
                        product.MapStyle<Product>(x => x.Name, new CellFill(hexColor: "FFFF0000"));
                    }

                    if(product.Price < 33)
                    {
                        product.MapStyle<Product>(x => x.Code, new CellBorder(left: true, right: true));
                    }

                    excelExportContext.RenderEntity(product, rowNo);
                }

                excelExportContext.SaveChanges();
            }
        
        }
コード例 #3
0
        public void Process()
        {
            using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(@"D:\product.xlsx", SpreadsheetDocumentType.Workbook))
            {
                var excelExportContext = new ExportContext(spreadsheetDocument);

                uint rowNo = 0;
                foreach (var product in _products)
                {
                    rowNo++;
                    if (product.Price > 44)
                    {
                        product.MapColumn <Product>(x => x.Description, "F");
                        product.MapStyle <Product>(x => x.Name, new CellFill(hexColor: "FFFF0000"));
                    }

                    if (product.Price < 33)
                    {
                        product.MapStyle <Product>(x => x.Code, new CellBorder(left: true, right: true));
                    }

                    excelExportContext.RenderEntity(product, rowNo);
                }

                excelExportContext.SaveChanges();
            }
        }