public async Task <ImportResult> Import(MemoryStream stream)
        {
            await _seedService.SeedNutritionalInfoType();

            using (ExcelPackage package = new ExcelPackage(stream))
            {
                Worksheet = package.Workbook.Worksheets.FirstOrDefault();

                var result = new ImportResult()
                {
                    Lines         = 0,
                    InsertedLines = 0
                };

                if (Worksheet != null)
                {
                    int rowCount = Worksheet.Dimension.Rows;
                    result.Lines = rowCount - 1;

                    Categories = (await _alimentCategoryRepository.GetAll()).ToList();
                    Aliments   = (await _alimentRepository.GetAll()).ToList();

                    for (int row = 2; row <= rowCount; row++)
                    {
                        if (await ProcessRow(row))
                        {
                            result.InsertedLines++;
                        }
                    }
                }

                return(result);
            }
        }
示例#2
0
 public IEnumerable <Aliment> Get()
 {
     return(_alimentRepository.GetAll());
 }
示例#3
0
 public List <AlimentDto> GetAll()
 {
     return(_alimentRepository.GetAll().Select(a => _mapper.Map <AlimentDto>(a)).ToList());
 }