Example #1
0
        public async Task <DocumentListModel> GetItems()
        {
            var data = await _documentsRepo.GetItems()
                       .ToListAsync();

            return(new DocumentListModel
            {
                Items = data.Select(x => new DocumentItemModel
                {
                    Id = x.Id,
                    WarehouseFrom = new WarehouseItemModel
                    {
                        Id = x.WarehouseFromNavigation.Id,
                        Name = x.WarehouseFromNavigation.Name
                    },
                    WarehouseTo = new WarehouseItemModel
                    {
                        Id = x.WarehouseToNavigation.Id,
                        Name = x.WarehouseToNavigation.Name
                    },
                    Product = new ProductItemModel
                    {
                        Id = x.Stock.Id,
                        Name = x.Stock.Name
                    },
                    Value = (int)x.Value
                }).ToList()
            });
        }